Reputation: 733
I intend to replace all the strings starting as style=" having anything in-between and ending with " . Am trying to use this call but it isn't working:
preg_replace('/style="*"/', '', $feed[$x]['desc']);
It is replacing only style=" and leaving the rest intact e.g. for style="border:1px solid red" am still getting border:1px solid red" after the replacement, which means that the * wildcard is wrong to be used here. How can I indicate that there can be anything in-between "" then ?
Thanks in advance !
Upvotes: 0
Views: 51
Reputation: 1473
in your pattern the wildcars is for the "
You should use ".*?"
or something like this
Upvotes: 0
Reputation: 38442
you obviously want everything except a quote character, so use /style="[^"]*"/
in regexes, the asterisk means "0 or more repetitions of the previous character"
Upvotes: 1