Jump to content

str_replace with only semi-known string that should be replaced


Nihilis

Recommended Posts

Hi everybody!

I'm Swiss, so my English could sound a little strange sometimes... sorry for that.

 

I have a Problem with str_replace().

 

I have a large string containing an unknown amount of the substring [CHECK-00] ([CHECK-01], [CHECK-02], [CHECK-04], [CHECK-05] ...) And now I want to use str_replace to replace all of them with a empty string: ''

 

Of course I could just count the number of "[CHECK-" substrings and replace them within a loop or something like this, but they are not always in a specific order. They could also be something like "[CHECK-87]{some substring}[CHECK-1]{some substring}" The only thing for sure is, that this [CHECK] substrings have always the same structure: "[" + "CHECK-" + {two numbers} + "]".

 

Is there any way to do this with a combination of str_replace and regex? Or do you have an other idea on how to solve this problem?

 

Any help is very welcome =)

 

Greetings from Switzerland,

Nihilis

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.