[Regular expression] how can I "match to end or end with a string", for example, MV & id = 17328895840 & scm = 102 and MV & id = 17328895840 can both be matched?

Source: Internet
Author: User
[Regular expression] how to & quot; match to end or end with a string & quot ;. for example, both MV & amp; id = 17328895840 & amp; scm = 102 and MV & amp; id = 17328895840 can be matched. example: str & nbsp ;=& nbsp; M [regular expression] ask how to "match to end or end with a string ". for example, both MV & id = 17328895840 & scm = 102 and MV & id = 17328895840 can be matched.
Example:

Str = MV & id = 17328895840 & scm = 102

Reg = "/& id = (./) &/U ";

You can get 17328895840

However, MV & id = 17328895840 cannot be matched.

I tried reg = "/& id = (./) [& | $]/U ";

I want to teach you how to write regular expressions to match both of them at the same time.

Thank you.
------ Solution --------------------
$ Reg = "/& id = (. + )(? :&
------ Solution --------------------
$)/U ";
------ Solution --------------------
$ Reg = "/& id = (. + ?) (&
------ Solution --------------------
$ )/";

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.