Jump to content

[SOLVED] Switching to regex?


Azu

Recommended Posts

Hello I'm used to using str_replace but now I want to switch to a regex solution since str_replace isn't working how I want it to work.

 

Can somebody please tell me how to use a regex function to act like str_replace, except without changing the capilization of letters?

 

For example, stri_replace('a test','<b>A test</b>','This is a test'); outputs '<b>A test</b>' (it changed the lowercase a to an upper case A).

 

How do I do it with a regex function so that it won't change the case?

 

This is for a search script that I am making, and have it change instances of the search phrase in the result to bold. It isn't supposed to change the case though. Please help.. I've never used regex before except copy and pasting regex that I found by searching, but I can't find this by searching.. x_x

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.