Reputation: 7768
I have a string with the following format,
some_string%value1:value2:value3:%some_anather_string%value4:value5:value6:%
I need to remove%value1:value2:value3:%
and %value4:value5:value6:%
from the string,i mean i need to remove any string with the format of starting with %
ending with :%
and values seperated with :
Is this possible?
I try with str_replace()
,But it work only we know the values.
Upvotes: 3
Views: 146
Reputation: 68526
Use can use this simple regex
echo $str = preg_replace("~%(.*?):%~","", $str);
Upvotes: 4