Preg replace Question

How can I modify the following preg_replace:


$glossary_search = '/[^>]('.preg_replace('/\\s+/', '\\s', $glossary_title).')[^<\\w](?=([^"]*"[^"]*")*[^"]*$)/i';

Where $glossary_title = “Creditor”
So that:

  1. It does not match where the searched for text is contained within an anchor, eg <a…> something creditor something</a>, won’t match (using lookarounds?).
  2. Will also match, Creditor’s, Creditors, Creditors’ as being the same.

Many thanks.

This is the updated one:

$glossary_search = '/(?<!>)('.str_replace('/\\s+/','\\s',$glossary_title).'(s|\\'s)?)(?!<)(?=([^"]*"[^"]*")*[^"]*$)/i';

Understand parts of it, but didn’t write it.
Still isn’t matching apostrophe keyword’s instances.

First, do you know what the current regular expression is doing and why?