Regular Expression To Match Inline JavaScript

A Regular Expression to match inline JavaScript and opening/closing <script> tags.

/<script[^>]*>[\w|\t|\r|\W]*<\/script>/

Matches:

  • <script>alert(‘OK’)</script>
  • <script src=”app.min.js”></script>

Non-matches:

  • <script>alert(‘OK’)
  • <a></a>
  • <h1 class=”demo”></h1>

See Also: