RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
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: The rating for this expression. Diogo Osório
   Displaying page 1 of 1 pages; Items 1 to 1

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials