Displaying page
of
pages;
Items to
Title |
Test
Details
PHP - Telefone Portugal | Portugal Phone
|
Expression |
/(?<=[^a-zA-Z0-9])((\+351|00351|351)?)(2\d{1}|(9(3|6|2|1)))\d{7}(?=[^a-zA-Z0-9])/
|
Description |
I've created this regex expression to parse portuguese phone numbers from an webpage.
As this was made with a very specific purpose, the expression expects the number to be preceded and followed by any character that's not a digit or a letter (basically space or "special" character).
This way I can parse any page with confidence that the results will be adequate.
I'd also recommend that you strip any spaces and "new line" from the haystack before matching it with this regex.
Here's an example: http://paste2.org/p/1610446
|
Matches |
<li>+351963345676</li> <a href="#">214664332</a> &00351923456321&
|
Non-Matches |
213322134 letters932213332 00351932213332letters
|
Author |
Rating:
Diogo Osório
|
Displaying page
of
pages;
Items to