-1

Below regex is not working in IE alone to remove the script tag from url:

Regex Pattern

(/(%3C*|<)[^*]?script(%3E)[a-zA-Z0-9]*/gi, '')

code:

var testEx= http://tv/header:1<script>as</script>;      
testEX = testEx.replace(/(%3C*|<)[^*]?script(%3E)[a-zA-Z0-9]*/gi, '');     
console.log(testEx);

Expected Output:

tv/header:1

Can you suggest the solution for this?

Manan Kapoor
  • 675
  • 1
  • 11
  • 28

1 Answers1

0

You can try the following regex:

/(%3C*|<)[/]?script(%3E|>)[a-zA-Z0-9]*/gi

What I have changed:

It now matches a an optional slash '/' before 'script', it also matches a literal '>' after 'script'.

If you now replace with an empty string, you get the expected result.

Poul Bak
  • 10,450
  • 5
  • 32
  • 57