I want to match the next element with a regular expression
target="#MOBILE"
and all valid options.
I wrote a regular expression
target[\s\S]*#MOBILE[^>^\s]*
which corresponds to the following
target="#MOBILE" target = "#MOBILE" target=#MOBILE target="#MOBILE" (followed directly by >)
but he does not match
target=" #MOBILE "
(pay attention to the extra space). It only matches
target=" #MOBILE
missing final quote
I need the ending expression [^>^\s]* match the quote only if it matches the quote at the beginning. It should also work with single quotes. The expression to be expressed must also end with a space or > char, as it is currently.
I am sure there is a way to do this, but I do not know how to do it. This is probably standard stuff - I just don't know it
I'm probably not sure that [^>^\s]* is the best way to complete if the regex gets into space or > char, but this is the only way to make it work.
source share