Regular expression Surround

Source: Internet
Author: User

1, look around is to see the meaning of the surrounding. Look around to match a location where some conditions are met. That is, the front and back of the location, containing some content, which does not contain some content.

2, for 12345678, modified to 12,345,678. The need to do this is to add a comma in some places in the number, which is characterized by a comma at the position of the rightmost number, and a three-digit multiple. As follows:

Replace with find (? <=\d) (? = (\d\d\d) + ([^\d]|$)), which means find a location, replace with,

(? <=\d) There's a number on the left.

(? = (\d\d\d) + ([^\d]|$)) has a multiple of three digits to the right, and the rightmost is not a number, or a line end.

You can also use (? <=\d) (? = (\d\d\d) + (?! \d)), (?! \d) indicates that the right is not a number.

Regular expression Surround

Related Article

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.