Title, my $data[' content ' has a lot of content, including an IMG tag:
I want to get rid of the/uploads/in the SRC attribute and save the rest. The regular is not how, ask the big God tell me how to filter, thank you
Reply to discussion (solution)
Preg_replace ("src="/uploads/([^ "]+?)" ', ' src= ' $ ', $data [' content '];
Preg_replace ("src="/uploads/([^ "]+?)" ', ' src= ' $ ', $data [' content '];
Thank you, the effect has been achieved. I want to know: in the regular [^]]+? What is the role?
^ except "all matches, + at least one,?" Non-greedy (as few as possible) matches
is to match the normal link to the back (the equivalent of "to make a match"), to represent the captured content
[^ "] not all characters of"
+? Non-greedy match
It's extra for use here.
[^ "] not all characters of"
+? Non-greedy match
It's extra for use here.
Ask, this regular (src= ". * (http://.*?)" Will it be better?