I am looking for a regular expression in PHP that will match an anchor with specific text on it. For example, I would like to get bindings with the text mylink, for example:
<a href="blabla" ... >mylink</a>
Therefore, it must correspond to all anchors, but only if they contain certain text. Therefore, it must match these lines:
<a href="blabla" ... >mylink</a>
<a href="blabla" ... >blabla mylink</a>
<a href="blabla" ... >mylink bla bla</a>
<a href="blabla" ... >bla bla mylink bla bla</a>
but not this one:
<a href="blabla" ... >bla bla bla bla</a>
Because this one does not contain the word mylink.
Also, this should not coincide: "mylink is string"because it is not an anchor.
Any idea?
Thanx granit
source
share