?
Solved

Regular Expression

Posted on 2011-03-19
6
Medium Priority
?
256 Views
Last Modified: 2012-05-11
I do not have expirience about Reg's and i need some help
this Regular :
\((?<AreaCode>\d{3})\)\s*(?<Number>\d{3}(?:-|\s*)\d{4})

Open in new window

gives me a result like (800) 325-3535 or (210) 556 3535
i need a regular expression like +30 (210) 5563535
First part is an international code (max 9 digit plus + at the begging)
second part is area Code max 6 digit within parenthesis
third part is the actual tel number max 10 digits
0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 8

Expert Comment

by:crysallus
ID: 35171495
This should match your current examples, as well as with the international extension added. In other words the international code is defined as optional here.

(?:(?<IntCode>\+\d{1,9}?)\s*)?\((?<AreaCode>\d{3})\)\s*(?<Number>\d{3}(?:-|\s*)\d{4})

Open in new window

If you don't want the international code to be optional, and only match numbers with the international code, then try this:

(?<IntCode>\+\d{1,9}?)\s*\((?<AreaCode>\d{3})\)\s*(?<Number>\d{3}(?:-|\s*)\d{4})

Open in new window

0
 
LVL 8

Accepted Solution

by:
crysallus earned 1000 total points
ID: 35171512
oops. Forgot about the other changes you mentioned in points 2 and 3. Try this, for optional international code:

(?:\+(?<IntCode>\d{1,9}?)\s*)?\((?<AreaCode>\d{1,6})\)\s*(?<Number>\d{1,10})

Open in new window

Not optional:

\+(?<IntCode>\d{1,9}?)\s*\((?<AreaCode>\d{1,6})\)\s*(?<Number>\d{1,10})

Open in new window

0
 
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35171521
You got it in your second post ...
thank you very much ....
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35171598
i try to inert a specified Set of [0-9] to accept only numbers and it Match also if with letter...
"Your Syntax is correct.." ..i try this
\+(?<IntCode>\d{1,9}?[0-9])\s*\((?<AreaCode>\d{1,6}?[0-9])\)\s*(?<Number>\d{1,10}?[0-9])

Open in new window

What am i missing?
0
 
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35171832
For example if i set +30 (210) 5564fffff then it return true....
0
 
LVL 18

Author Comment

by:John (Yiannis) Toutountzoglou
ID: 35171836
My expression is
\+(?<IntCode>\d{1,9}?)\s*\((?<AreaCode>\d{1,6})\)\s*(?<Number>\d{1,10})

Open in new window

0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question