I'm using the DOMDocument and DOMXPath to determine the presence of some phrase (Keyword phrase) in my HTML content, for example to search if the Keyword is in Bold. I use the follow code and works fine except that I need to "ignore" some characters when the keyword is searched. With the follow code:
$characters_to_ignore = array(':','(',')','/');
$keyword = 'keyword AAA';
$content = "Some HTML content for example <b>keyword: AAA</b> and other HTML";
$exp = '//b[contains(., "' . $keyword . '")]|//strong[contains(., "' . $keyword . '")]|//span[contains(@style, "bold") and contains(., "' . $keyword . '")]';
$doc = new DOMDocument();
$doc->loadHTML(strtolower($content));
$xpath = new DOMXPath($doc);
$elements = $xpath->query($exp);
I would need to identify "keyword: AAA" as well as "keyword AAA", so I need to specify to the DOMXPath query to ignore the characters in variable $characters_to_ignore when search for the keyword phrase.
The previous code works fine for "keyword AAA", how can I change it to match "keyword: AAA" too? (and with any of the characters in $characters_to_ignore)
New Information: Maybe using this?
fn:contains(string1,string2)
but I can't get a working example.