This may be a simple one but I can't seem to find the answer to it.
I have a string in a HTML file that I am looking for:
<div class="button" onclick="docu开发者_运维百科ment.$name.submit(); return false\">Save</div>
where $name is is generated by code, so can be anything.
I need to write a PCRE regular expression that will find this string in the file but disregard the $name section of the string.
I have tried this :
/<div class=\"button\" document.(.+?).submit\(\); return false\">Save<\/div>/
It will return the group that equals to what is in $name. but not define it as a match, which is what I need.
The following should work:
/<div class="button" onclick="document\.(.+?)\.submit\(\); return false">Save<\/div>/
Most likely your problem was that you forgot to escape the parenthesis after submit()
, so it tried to match submit;
.
Try this
@<div class="button" onclick="document.(.*?).submit\(\); return false">Save</div>@
精彩评论