Jump to content

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

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.