Jump to content

Recommended Posts

Unless you're reading in a plain text file, there will always be HTML tags around your chosen word; unless you really mean something much more specific like literally, only, around the word itself?  Could you elaborate a little more on precisely what you want to accept as matching and what you want to disallow from matching?

 

Also, if you've made a start on matching the word but cannot quite adapt that to looking for tags, post up any regex that you have at the moment for us to help you to adapt it. :)

It would be sufficient to determine whether the word is in anchor tags.

Right now I have an array of regular expressions and an array of replacement strings.

I use preg_replace to perform the replacement.

I have about 700 words in my search array.

$search = array("/\bAAA tenant\b/i","/\babandonment\b/i");
$replacement = array('<a href="/words/aaa-tenant">AAA tenant</a>','<a href="/words/abandonment">abandonment</a>');
preg_replace($_search, $_replacement, $content);

 

 

 

 

-Brian

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.