Try this:
$remove = preg_replace('/[0-9]+\:/', '', $postcodes_id);
Adding the +
means "one or more digit" instead of your code which is "just one".
I'm pretty sure you don't need the \
before the :
...
Question
I am trying to remove parts of a string which has an ID and : before it. So for example:
2846:ZE1,2847:ZE2,2848:ZE3,713:DY10,412:CF10
But I want it to look like this:
ZE1,ZE2,ZE3,DY10,CF10
I have tried the following preg_replace:
$remove = preg_replace('/[0-9]\:+/', '', $postcodes_id);
But this only removes the last digit and not all of it:
284ZE1,284ZE2,284ZE3,71DY10,41CF10
any help would be great?
Solution 2
Try this:
$remove = preg_replace('/[0-9]+\:/', '', $postcodes_id);
Adding the +
means "one or more digit" instead of your code which is "just one".
I'm pretty sure you don't need the \
before the :
...
OTHER TIPS
You have the +
in the wrong place, it should be:
preg_replace('/[0-9]+:/', '', $postcodes_id);
You also don't need to escape :
, it has no special meaning in regular expressions.