Replace a string with a string that contains multiple & quot; # xxxxx # & quot; substrings. what should I do if I want to convert these substrings into other strings? # Xxxxx # Convert to & lt; imgsrc = & quot; xxxxx & quot;/& gt;, that is, extract the characters in # and replace the entire # xxx string
There is a string with multiple substrings such as "# xxxxx #". what should I do if I want to convert these substrings into other strings?
# Xxxxx # is to extract the characters in # and replace # xxxxx #
$ Html = '# xxxxx ## xxxxx #';
$ Str = "# xxxxx #";
$ Str = str_replace ('# xxxxx #', '', $ html );
Echo $ str;
What about regular expressions? Please advise
------ Solution --------------------
Echo preg_replace ('/# ([^ #] + ?) #/Is ', '', $ html );
------ Solution --------------------
Replace (the replaced string), the regular expression depends on what you are replacing and replacing. we recommend that you use replace
------ Solution --------------------
Modifier/u
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service