Friday, 3 February 2017
Regex match for HTML tag containing "on" JS trigger
Answer
Answer
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:
onblur="foo()"/>Other stuff
I've got most of this to work using the pattern:
<\w+([^>])+?(on\w+)+[\s\S]+?>
However, this also matches:
Other stuff
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.
Answer
Might work <\w+(?=\s)[^>]*?\s(on\w+)[\s\S]+?>
Subscribe to:
Post Comments (Atom)
c++ - Does curly brackets matter for empty constructor?
Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...
-
A fair amount of the second act of The Dark Knight Rises has a class warfare plotline. This is foreshadowed in the trailers with Selina Ky...
-
I want to create an options array from a string. How can i create an array as { width : 100, height : 200 } from a string ...
-
I'm trying to set the size of a CardView inside of a DialogFragment , but I get this error: java.lang.NullPointerException: Attempt t...
No comments:
Post a Comment