How to solve regular expression match and replace some characters

Source: Internet
Author: User
Regular expression match and replace some characters $ aaa = & quot; aaa; bbb; ccc; ddd; eee; fff; & quot; with: & quot; aaa * bbb; ccc * ddd; eee * fff; & quot; do not use php! I just want to replace the regular expression. I don't know who can help solve this problem. The real regular expression matches and replaces some characters.
$ Aaa = "aaa; bbb; ccc; ddd; eee; fff ;"

Replace it with: "aaa * bbb; ccc * ddd; eee * fff ;"

Do not use the php method!

I just want to replace the regular expression. I don't know anyone who can help solve this problem. I really can't think of it!
The purpose is to replace odd digits with * even digits!

Thank you ~

------ Solution --------------------
Echo preg_replace ('/(\ w +); (\ w +)/', '$1 * $ 2', $ aaa );
------ Solution --------------------
It should be replaced once every other time, right?
PHP code
$ Aaa = "aaa; bbb; ccc; ddd; eee; fff;"; echo preg_replace ('# \ G [^;] + \ K; ([^;] + ;?) # ',' * \ 1', $ aaa );

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.