Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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"  önblur="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]+?>

While this fixes the false positive, it requires the "onsomething" keyword to be preceded by 2 or more whitespace characters for a match to occur.  A nudge in the right direction would be appreciated.

/ravi
Posted

1 solution

Answered on SO[^].

/ravi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900