Regex match for HTML tag containing "on" JS trigger

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+([^>])+?(onw+)+[sS]+?>

However, this also matches:

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

I modified the original pattern to:

    <w+([^>])+?(s)+(onw+)+[sS]+?>

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.


可能工作<w+(?=s)[^>]*?s(onw+)[sS]+?>


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

尝试是否包含这将匹配HTML on ,但不会匹配它,如果它是中期字

链接地址: http://www.djcxy.com/p/13412.html

上一篇: 为什么正则表达式在不止一个#时不匹配?

下一篇: 正则表达式匹配包含“on”JS触发器的HTML标记