开发者

another regex email post (in php)

开发者 https://www.devze.com 2022-12-13 09:19 出处:网络
Im handling various email addresses that come in the following forms John Doe <5555555555@mail.com>

Im handling various email addresses that come in the following forms

John Doe <5555555555@mail.com>
5555555555@mail.com

How could i use regex, to find the @ symbol, and then return the integer's behind it (u开发者_如何学编程ntil it doesnt find anymore, or runs into a non number, < or space for example.)


/^\D*(\d*)@/

Will match any number of non-digits, any number of digits, followed by an @.

The capturing group will contain the digits.


Just search for this regex:

(\d*)@

And then look at the first capture group.


You could try something like...

preg_match("#^[\D]+\<([\d]+)#", "John Doe <5555555555@mail.com>", $matches);
0

精彩评论

暂无评论...
验证码 换一张
取 消