Why Nostr? What is Njump?
2024-08-22 13:15:08

Paul on Nostr: Does anyone know if there's a way to do case-insensitive search + replace in PHP, but ...

Does anyone know if there's a way to do case-insensitive search + replace in PHP, but retain the original case, for highlighting search keywords?

For example, if I want to make the search results bold, searching for 'paul' in 'Paul Waring' should return:

<b>Paul</b> Waring

and not:

<b>paul</b> Waring

str_ireplace does nearly everything I need, but doesn't retain the original case. Maybe preg_replace with capture groups?

#php
Author Public Key
npub1e5frt7j9xgjmzhfxxvq5e9dv08tl8zrxn69gzkqwexgmj90l3ryqlnx7jr