Possible duplicate:Open RegEx tags, with the exception of stand-alone XHTML tags
I have an HTML page with
<a class="development" href="[variable content]">X</a>
[variable contents] is different in every place, the rest is the same.What will regexp catch all these links? (Although I am not writing here, I really tried ...)
How about a non-greedy version:
<a class="development" href="(.*?)">X</a>
Try this regex:
<a class="development" href="[^"]*">X</a>
Regexes HTML (. , XML HTML ? ). HTML. . HTML ? .
Regex, , HTML, , , . , ,
<a class="development" href="[variable content]">X </a>
?
JQuery, :
$("a.development").onclick = function() { return false; }
$("a.development").attr("href", "#");
, href.
href
/<a class="development" href=(?:"[^"]*"|'[^']*'|[^\s<>]+)>.*?<\/a>/m
I also assume that it Xwill be a variable, so I added a non-greedy match to handle it, which /mmeans .also matches line breaks.
X
/m
.