user2631496 user2631496 - 1 month ago 7
PHP Question

exclude results found inside anchor text

I am trying to use regex in php to find all the words count excluding the ones located in the anchor text

I start with /\b(count)\b/i but can not get exactly what I need

Cycle count Stored as a <a href="poem://plaspoem/POEM?LOC=MAIN&CMD=VIEW&KEY=CYCLE COUNT&REV=A">Cycle count</a> which is a count of records Cycle count`

Answer

You'll can use negative lookahead:

/count(?!<\/a>)(?!&)/i

Matches: Cycle count Stored as a <a href="poem://plaspoem/POEM?LOC=MAIN&CMD=VIEW&KEY=CYCLE COUNT&REV=A">Cycle count</a> which is a count of records Cycle count

EXAMPLE

Comments