Solved

Regular Expression

Posted on 2011-03-19
6
253 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 250 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with opening combobox using VB.NET. 3 38
How to identify a paragraph in the body of text? 2 56
VB.net Is there code behind PowerPivot 2 52
"lblTime is not declared" 3 36
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

730 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