How can I solve this problem by finding a simple regular expression?

Source: Internet
Author: User
Find a simple regular expression $ str = & quot; & lt; ahref = 'XXX' title = 'August 5 5' & gt; February 5, & lt;/a & gt; & lt; imgsrc = 'XXX' alt = 'August 5 5' & gt ;... & quot; now I just want to replace the character "3-4" displayed on the page in the above string with "3-4" and "3-4" for a simple regular expression.
$ Str = "February 5, 1234 ...";
Now I just want to replace the character "3, 4" displayed on the page of the above string with "3, 4", and "3, 4" without moving any character in the hypertext tag. the replacement result is as follows:
$ Str = "one, two, three, five ...";
How can I write this statement? Thank you.

------ Solution --------------------
PHP code
$ Str = "February 5, 1234 5, 1234 5, 1234 5, 1234 5 \ n..."; echo preg_replace ('/3rd 4 (?! [^ <] +>)/', 'San si', $ str );

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.