how would I use regex to match a word, let's say "the" but only if it's not part of a link in any shape or form so <a href="NOT IF IT'S IN HERE">AND NOT IF IT'S IN HERE</a>
DonWilson
Jun 2 2005, 09:31 PM
I'd suggest looking for <a >...</a> and replacing that whole thing with a blank statement, instead of trying to find the text out side of it.
Trel
Jun 2 2005, 11:16 PM
no you don't understand, look at the example below
I have the following html
CODE
<a href="www.thesite.com">the best site</a> Click the link
now I want it to match the word "the" in "click the link" but not in the "thesite.com" or "the best site"
that's what I'm trying to do.
primetime
Jun 3 2005, 06:56 AM
You could try doing:
CODE
<?php -- fubared --- ?>
GAH.... IPB is breaking the code...
OOoo..k...
Well let's try this.. since IPB is breaking it..
CODE
</a>(.+|040|)(the)(040|.+|<|)
primetime
Jun 3 2005, 07:12 AM
Hmm.. ok.. I guess not.. just escape the / of the </a> in my post above and if you're using preg_match("/".$postabove."/i", $linetoberegexed, $match); it's $match[2];
Trel
Jun 3 2005, 10:41 AM
That doesn't look like it'd work though because what if I had a "the" before the closing of the first <a>, that one would not be matched
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.