regular epression?

  • Thread starter Thread starter perspolis
  • Start date Start date
P

perspolis

I used a regular expression and I want to find any sentences between "<script" and "</script?"
and the pattern I used it's here
String regstr=@"(<script((?!</script>)(\w|\W))+</script>)";

but it dosen't sometimes work...pls help me??
 
I used a regular expression and I want to find any sentences between "<script" and "</script>"
and the pattern I used it's here
String regstr=@"(<script((?!</script>)(\w|\W))+</script>)";

but it dosen't sometimes work...pls help me??
 
perspolis said:
I used a regular expression and I want to find any sentences between
"<script" and > "</script?"
and the pattern I used it's here
String regstr=@"(<script((?!</script>)(\w|\W))+</script>)";
but it dosen't sometimes work...pls help me??


Please don't post HTML-text if it isn't absolutely neccessary.

I've tried your regex (on this email's text), and it does seem to work.
Could you post sample data where it doesn't?

Niki
 
it works with most of pages...but with yahoo pages sometimes doesn't work..
I mean with yahoo pages it works but not completely..it doesn't return all
of
matches in yahoo pages...
 
perspolis said:
it works with most of pages...but with yahoo pages sometimes doesn't
work..
I mean with yahoo pages it works but not completely..it doesn't return all
of
matches in yahoo pages...

If you could post a string where it doesn't work, I'd have a look at it.

If you only want general advices, here are a few:
- "\w|\W" does exactly the same as ".", it matches any character
- I'd use lazy quantifiers instead of negative lookahead (should be faster)
- This won't work if the script contains the text "</script>", e.g. in a
string or comment.

General advice (no offense meant): Always post all the information you have,
to increase your chances of getting help...

Niki
 
thx for ur helping :)
Niki Estner said:
If you could post a string where it doesn't work, I'd have a look at it.

If you only want general advices, here are a few:
- "\w|\W" does exactly the same as ".", it matches any character
- I'd use lazy quantifiers instead of negative lookahead (should be faster)
- This won't work if the script contains the text "</script>", e.g. in a
string or comment.

General advice (no offense meant): Always post all the information you have,
to increase your chances of getting help...

Niki
 
Back
Top