Avatar of willsherwood

asked on 

PHP regex how to replace with the same string

the following statement works:

$display_html =
   "<b class='highlight'>".$search_string."</b>",
    $row['title'] );

where search_string is what is being searched for, and 'title'
is the  LIKE-matching result from a mysql database.

currently the regex substitutes the CASE that was used as typed in by the searcher.
I would like to have the CASE retained to that of what the field was in the database
(could be lower, initial cap, all caps, etc.)

how can the regex substitution (which surrounds the title search phrase with HTML tags for highlighting)
be altered to retain the the capitalization in the returned field result.

Avatar of undefined
Last Comment

8/22/2022 - Mon