This has to do with searching. When something is found, display the search results, but bold the search terms in the item title and item description.
What shouldn't happen is that if a searched-for term is part of the anchor "<a href='/products/items/platinum/'>" tag, then html code is not inserted around the term in the "href=" as the products page gets compiled and spit out.
Take a search for the word "platinum".
One item returns a description of "This is a fine platinum item. <a href='/items/platinum/1234/'>read more</a>."
What should get spit out with a preg_replace is:
preg_replace("match $_POST['searchterm']", "replace with <b>$searchterm</b>", "do this to item description")
The conditions are:
-Only match $_POST["searchterm"] when "href=" is not located before a space, or an ending ">" to the left of the term.
-Only match $_POST["searchterm"] when /' or /" is not found before a space to the right of the term.
-Case insensitive
I created the query correctly in C/C++ regex below:
(href={0})(.*[^ ]|.*[^>])(searchterm)(?!.*[^ ]/\"|.*[^ ]/')
Then I tried to insert it into my script, and it didn't work. Go figure!!








Bookmarks