"jumpstart" <jumpstart101@g mail.com> writes:
[color=blue]
> I need a RegEx to validate INTERNATIONAL PHONE NUMBRES.[/color]
Don't shout, please.
Anyway, tell me what the format of these international phone numbers
are, and I can tell you how to validate them.
My guess is that the format is a plus ("+") followed by at least two
digits (probably more, but the country code can be only digit, and
I don't know all nation's phone numbers). To check for that, a RegExp
could be /^\+\d\d+$/
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
JRS: In article <is1pqy1p.fsf@h otpop.com>, dated Wed, 11 May 2005
22:59:14, seen in news:comp.lang. javascript, Lasse Reichstein Nielsen
<lrn@hotpop.com > posted :[color=blue]
>"jumpstart" <jumpstart101@g mail.com> writes:
>[color=green]
>> I need a RegEx to validate INTERNATIONAL PHONE NUMBRES.[/color][/color]
[color=blue]
>Anyway, tell me what the format of these international phone numbers
>are, and I can tell you how to validate them.[/color]
There is AFAIK no standard in use for the written format, except that it
needs a minimum number of decimal digits. One must allow at least 18,
28, or 32 digits, depending upon which authority one believes - see
I.T.U. documents, and maybe
Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!
The dialled format must contain only characters which the dialler is
known to understand or ignore.
[color=blue]
>My guess is that the format is a plus ("+") followed by at least two
>digits (probably more, but the country code can be only digit, and
>I don't know all nation's phone numbers). To check for that, a RegExp
>could be /^\+\d\d+$/[/color]
Since there are more than 100 indisputable countries, more than two
digits are unavoidable.
Three suffice if certain countries are considered as telephonic parts of
others : the Faeroes answer to 45 42, so presumably Denmark proper has
no area code 42. BVI answers to 1 809 49, Cayman Is to 1 809 94,
Dominican Republic to 1 809, Dominica to 1 809 449, Grenada to 1 809
444, Jamaica to 1 809, ... . Vatican City State answers to 39 66982.
(Caution - those may have changed since my reference was printed.)
If the number is known to be international, there is no real need for a
"+"; that's used when indicating both the international and internal
numbers at once.
One could validate the international access code, if the user is called
upon to provide that and the dialling provider is known and a list of
access codes is maintained.
One could validate the code for the country, at the price of maintaining
a list for all countries except the USA.
Otherwise, consider
X = TN.replace(/\D/g, "").length
OK = X>7 && X<33
where TN is the putative number and 7 is a very safe guess.
Combined, perhaps, with something like
OK = /^[0-9()+ -]*$/.test(TN)
if there is a need to accept only reasonable punctuation.
jumpstart wrote on 12 mei 2005 in comp.lang.javas cript:
[color=blue]
> I need a RegEx that allows
>
> dashes, spaces, parenthesis, dots and alphabets both small and
> capital..
>
> that is, for example
>
> 1.800.444.345 5678
>
> 1.456.444.345 5678 Extn:900
>
> 1 (567) 454 5767[/color]
You don't need a regex for that, they are allowed by defaoult.
Or are you replying on something without quoting?
That is "not done" on usenet.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
So it shouldn't allow quotes, double quotes, asterik, dollar sign etc..
thats why I need a regex that allows...
plus, dashes, spaces, parenthesis, dots and alphabets both small and
capital..
that is, for example
1.800.444.345 5678
1.456.444.345 5678 Extn:900
1 (567) 454 5767
+91 044 454 5767
Evertjan. wrote:[color=blue]
> jumpstart wrote on 12 mei 2005 in comp.lang.javas cript:
>[color=green]
> > I need a RegEx that allows
> >
> > dashes, spaces, parenthesis, dots and alphabets both small and
> > capital..
> >
> > that is, for example
> >
> > 1.800.444.345 5678
> >
> > 1.456.444.345 5678 Extn:900
> >
> > 1 (567) 454 5767[/color]
>
> You don't need a regex for that, they are allowed by defaoult.
>
> Or are you replying on something without quoting?
>
> That is "not done" on usenet.
>
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)[/color]
jumpstart wrote on 12 mei 2005 in comp.lang.javas cript:[color=blue]
> Evertjan. wrote:[color=green]
>> jumpstart wrote on 12 mei 2005 in comp.lang.javas cript:
>>[color=darkred]
>> > I need a RegEx that allows
>> > dashes, spaces, parenthesis, dots and alphabets both small and
>> > capital..
>> > that is, for example
>> > 1.800.444.345 5678
>> > 1.456.444.345 5678 Extn:900
>> > 1 (567) 454 5767[/color]
>>
>> You don't need a regex for that, they are allowed by defaoult.
>> Or are you replying on something without quoting?
>>
>> That is "not done" on usenet.[/color]
> So it shouldn't allow quotes, double quotes, asterik, dollar sign etc..
> thats why I need a regex that allows...
> plus, dashes, spaces, parenthesis, dots and alphabets both small and
> capital..
>
> that is, for example
>
> 1.800.444.345 5678
>
> 1.456.444.345 5678 Extn:900
>
> 1 (567) 454 5767
>
> +91 044 454 5767[/color]
result = !/[^\w\.\s\(\)\-\:]/g.test(myString )
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
jumpstart wrote on 12 mei 2005 in comp.lang.javas cript:
[color=blue]
> Ok! Here is my PROPER Message.
>
> I need a regex that allows...
>
> PLUS, dashes, spaces, parenthesis, dots and alphabets both small and
> capital..
>
> that is, for example
>
>
> 1.800.444.345 5678
>
> 1.456.444.345 5678 Extn:900
>
> 1 (567) 454 5767
>
> +91 044 454 5767
>
> (So it shouldn't allow quotes, double quotes, asterik, dollar sign
> etc.. )[/color]
Again, you don't quote, which is against netiquette,
so I will stop helping you.
You souldn't make me search for earlier postings.
btw, with the help you got so far,
you should be able to figure it out for yourself.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Evertjan. wrote:[color=blue]
> jumpstart wrote on 12 mei 2005 in comp.lang.javas cript:
>[color=green]
> > Ok! Here is my PROPER Message.
> >
> > I need a regex that allows...
> >
> > PLUS, dashes, spaces, parenthesis, dots and alphabets both small[/color][/color]
and[color=blue][color=green]
> > capital..
> >
> > that is, for example
> >
> >
> > 1.800.444.345 5678
> >
> > 1.456.444.345 5678 Extn:900
> >
> > 1 (567) 454 5767
> >
> > +91 044 454 5767
> >
> > (So it shouldn't allow quotes, double quotes, asterik, dollar sign
> > etc.. )[/color]
>
> Again, you don't quote, which is against netiquette,
> so I will stop helping you.
> You souldn't make me search for earlier postings.
>
> btw, with the help you got so far,
> you should be able to figure it out for yourself.
>
> --
> Evertjan.
> The Netherlands.
> (Replace all crosses with dots in my emailaddress)[/color]
JRS: In article <Xns9654D4E2384 24eejj99@194.10 9.133.29>, dated Thu, 12
May 2005 18:55:38, seen in news:comp.lang. javascript, Evertjan.
<exjxw.hannivoo rt@interxnl.net > posted :[color=blue][color=green]
>> So it shouldn't allow quotes, double quotes, asterik, dollar sign etc..
>> thats why I need a regex that allows...
>> plus, dashes, spaces, parenthesis, dots and alphabets both small and
>> capital..
>>
>> that is, for example
>>
>> 1.800.444.345 5678
>>
>> 1.456.444.345 5678 Extn:900
>>
>> 1 (567) 454 5767
>>
>> +91 044 454 5767[/color]
>
>result = !/[^\w\.\s\(\)\-\:]/g.test(myString )
>[/color]
I think you've missed a point - he explicitly says "alphabets" .
Now AIUI the first character of IJssel, when properly written, is (or
was) IJ, a part of the Dutch alphabet, which I expect to be represented
by something in the range \u0000 to \uFFFF. I rather doubt whether
that, or the various Continental accented characters, will be permitted
by your RegExp. Certainly it dislikes e-acute, so Tél : 010 33 44 55
.... would be rejected.
Perhaps the OP is monoglot, though?
Can one be sure that a telephone number, including "extension" , needed
for the OP's purpose cannot contain a * or # ? Buttons for those are
supplied on telephones.
The OP needs to give a carefully considered list indicating clearly all
characters which are to be accepted and no others.
Dr John Stockton <spam@merlyn.de mon.co.uk> writes:
[color=blue]
> I rather doubt whether that, or the various Continental accented
> characters, will be permitted by your RegExp.[/color]
Indeed. The character class "\w" covers exactly [a-zA-Z0-9_], and nothing
but. It would be fantastic to have a RegExp character class that covers
all Unicode word characters, but ECMAScript doesn't have it.
/L
--
Lasse Reichstein Nielsen - lrn@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
JRS: In article <4qd7yooe.fsf@h otpop.com>, dated Fri, 13 May 2005
20:18:57, seen in news:comp.lang. javascript, Lasse Reichstein Nielsen
<lrn@hotpop.com > posted :[color=blue]
>Dr John Stockton <spam@merlyn.de mon.co.uk> writes:
>[color=green]
>> I rather doubt whether that, or the various Continental accented
>> characters, will be permitted by your RegExp.[/color]
>
>Indeed. The character class "\w" covers exactly [a-zA-Z0-9_], and nothing
>but. It would be fantastic to have a RegExp character class that covers
>all Unicode word characters, but ECMAScript doesn't have it.[/color]
Agreed, except that for most purposes \u00646 and \u0077 cannot appear
in the same word, and it would be nice to have language-dependence.
RegExp \w should really have been \i : 0-9_ can appear in identifiers,
but not in English words. OTOH, an English word can contain a character
other than A-Za-z : greengrocer's o'clock .
Then in American, AIUI, the exclamation mark is not a word character; in
English, there is at least one, but probably only one, peculiar
instance, Ho! , in which it is; but it's common in at least one South
African language.
Lasse Reichstein Nielsen wrote:
[color=blue]
> "jumpstart" <jumpstart101@g mail.com> writes:[color=green]
>> I need a RegEx to validate INTERNATIONAL PHONE NUMBRES.[/color]
>
> [...]
> My guess is that the format is a plus ("+") followed by at least two
> digits (probably more, but the country code can be only digit,[/color]
Pardon? The telephone country code for Germany is 49, 41 for Switzerland
and 43 for Austria.
[color=blue]
> [...][/color]
Thomas 'PointedEars' Lahn wrote on 16 mei 2005 in comp.lang.javas cript:
[color=blue][color=green]
>> My guess is that the format is a plus ("+") followed by at least two
>> digits (probably more, but the country code can be only digit,[/color]
>
> Pardon? The telephone country code for Germany is 49, 41 for Switzerland
> and 43 for Austria.
>[/color]
Yes, and, besides 1 for USA/Canada and 7 for Russia 352, for Luxemburg.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)
Comment