Regular expression for validate

  • Thread starter Thread starter PawelR
  • Start date Start date
P

PawelR

Hello everybody,
I have problem with regular expression.
I want "code" telephon number and I have two types number:
1) [xx] [xxx xxx xxx] or
2) [xx] ([xx] or [xxx]) [xxx xx xx]
where x - is digital

Maybe someone know where is simple description regular expression - for
complitly beginner.

Thx
 
Hi Pawel,

Look for "Regular Expression" in VS .NET docs.

SAMPLE - Rational number:

(([0-9]+.[0-9]*)|([0-9]*.[0-9]+)|([0-9]+))

"[0-9]" means that any digit from 0 to 9
(or use ":d" instead)
"+" - one or more occurence
"*" - zero or more occurence
"|" - or expression

E.g. polish post code pattern (but i don't test it):
^[0-9][0-9]-[0-9][0-9][0-9]$
or
^:d:d-:d:d:d$

HTH
Marcin
 
Hi,

The following expression should take care of your syntax requirements.

\[\d{2,3}\]\s((\(\[\d{2,3}\]\))?)\s\[\d{3}\s?\d{3}\s?\d{3}\]

Just stick the cheque in the post. ;-)
 
Back
Top