Reg Ex for Script Tags
I thought it might be nice to have a little archive of Javascript Regular Expressions for other people coming through.
This one is for pulling <script> tags out of a string. It should match any case, account for attributes in the opening tag, and match any code including line breaks in between the tags.
First up, a code to jut match an opening <script> tag, because any open <script> tag can screw up a page, so you might want to take care of just that:
/<[Ss]*?script(s[Ss]*?)?>/gi
Next, a tag to grab a <script> tag from beginning to end, so that you can protect all the text, or replace it, or what have you.
/<[Ss]*?script(s[Ss]*?)?>[Ss]*?<[Ss]*?/script(s[Ss]*?)?>/giTags: No Tags























