Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Regexp Headache  RSS feed

 
Tobi Sasse
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,

I want to remove all script tags from a string containing html sourcecode. Unfortunately the regexp dies.



which results in:



Any ideas? Would be nice to have this running soon :-)

Thanks,
Tobi


PS: This is what the input looks like (just an arbitrary example)

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Byte Twentythree", please check you Private Messages for an important administrative matter.
 
Tobi Sasse
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:"Byte Twentythree", please check you Private Messages for an important administrative matter.


Sorry, got it. Any ideas on the topic?
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, this is my guess:
Have you tried this:

Also,
Its possible for you to get the index for <script> and </script> and then just replace that range with "" string.
 
Tobi Sasse
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Yea, I already tried this, but it doesn't work, cause "." does not include line termination symbols.
So if you have linebreaks or stuff in your script tag than the regexp does not match.

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What about this ?

 
Tobi Sasse
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys,

I found the solution in another board. This is the way you want to do this:



See http://forums.sun.com/thread.jspa?threadID=5406636&tstart=0

Thanks for your help anyway!
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's why they suggest SearchFirst
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!