-4

In my java application, we are using existing regex as below:

Regex = </*|[^\w\p{L} !#$%&'+,./:=?@|-]|&#|^'|'$|\W'|'[^\w\s]|script:

The above regex removes the character from script tag i.e. <>() but I want to remove the whole script tag along with word "script".

Input String:

<script>alert("asdf")</script>

Output String :

scriptalertasdfscript

Expected Output String :

blank

Please help.

flyingfox
  • 13,414
  • 3
  • 24
  • 39
Manan Kapoor
  • 675
  • 1
  • 11
  • 28

1 Answers1

1

Try with this:

<script[^>]*>.*?<\/script>

Demo

Julio
  • 5,208
  • 1
  • 13
  • 42
  • Is it possible to add this in the regex which I have provided? – Manan Kapoor Oct 05 '18 at 11:31
  • Try to update your original regex adding the new one at the beggining, for example: ` – Julio Oct 05 '18 at 11:42