0

I want to check if an HTML tag (potentially split across multiple lines) contains an "on" JS trigger. The actual HTML tag and the Javascript are of no consequence. For example:

    <img src="foo.jpg" onblur="foo()"/>Other stuff

I've got most of this to work using the pattern:

    <\w+([^>])+?(on\w+)+[\s\S]+?>

However, this also matches:

    <p style="font-size:11px;">Other stuff</p>

I modified the original pattern to:

    <\w+([^>])+?(\s)+(on\w+)+[\s\S]+?>

but this matches only if the JS trigger keyword is preceded by 2 or more whitespace characters. A nudge in the right direction would be appreciated.

2 Answers2

0

Might work <\w+(?=\s)[^>]*?\s(on\w+)[\s\S]+?>

0
(?m)(?i).*(?=([^a-z]on)).*>

Try this will match the html if it contains an on but wont match it if it is mid word

Srb1313711
  • 2,017
  • 5
  • 24
  • 35
  • The multi-line modifier won't let the last `.*`> span newlines (if it had to match > next). –  Dec 06 '13 at 17:40