another regex email post (in php)
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);
精彩评论