Php Regular Expression extracts all email addresses in the text, not one email address

Source: Internet
Author: User
Tags php regular expression preg
Php extract all the mailbox addresses in the text, or all the mailbox addresses in a string, for example, my text is: the Chinese character is scddtest001@qq.comasdatest002 @ qq.com after you amtest009@aa.com matching results should be test001@qq.comtest002 @ qq. comtest009 @... php extracts all email addresses in the text, or all email addresses in a string
For example, my text is:
Chinese character is scdd test001@qq.com asda test002@qq.com after you am test009@aa.com
The matching result should be
Test001@qq.com
Test002@qq.com
Test009@aa.com
My code is as follows;


  

Currently only one Email address can be matched to the test001@qq.com, the other two currently do not match, to use greedy pattern match?
Please advise !!

Reply content:

Php extracts all email addresses in the text, or all email addresses in a string
For example, my text is:
Chinese character is scdd test001@qq.com asda test002@qq.com after you am test009@aa.com
The matching result should be
Test001@qq.com
Test002@qq.com
Test009@aa.com
My code is as follows;


   

Currently only one Email address can be matched to the test001@qq.com, the other two currently do not match, to use greedy pattern match?
Please advise !!

Problem solved
Use preg_match_all

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.