.NETGURU
help on regexp!
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngregexp' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Matias Woloski
Hi! I have to test some phones entered into a textarea. So for example
someone enter this:
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>
What I want to check is that the user enter a valid phone with this regex
((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}

but also I want to check that the number of phones entered to be <= 10
between phones there are Enters

so this is correct
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>

but this not
<textarea>
(123) 233222 <-- not valid phone
(124) 2334-1222
</textarea>

this is not correct
<textarea>
valid phone 1
valid phone 2
valid phone 3
valid phone 4
...
valid phone 10
valid phone 11 <-- there must be 10 phones only!
</textarea>

thanks in advance,
Matias

Reply to this message...
 
    
dagon
Basically,

^(((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}(\r?\n)?){1,10}$

-----Original Message-----
From: Matias Woloski [mailto:Click here to reveal e-mail address]
Sent: Sunday, November 04, 2001 00:16
To: aspngregexp
Subject: [aspngregexp] help on regexp!

Hi! I have to test some phones entered into a textarea. So for example
someone enter this:
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>
What I want to check is that the user enter a valid phone with this regex
((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}

but also I want to check that the number of phones entered to be <= 10
between phones there are Enters

so this is correct
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>

but this not
<textarea>
(123) 233222 <-- not valid phone
(124) 2334-1222
</textarea>

this is not correct
<textarea>
valid phone 1
valid phone 2
valid phone 3
valid phone 4
...
valid phone 10
valid phone 11 <-- there must be 10 phones only!
</textarea>

thanks in advance,
Matias

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
dagon
Oops, that would allow "(123) 2334-1222(123) 2334-1222" for example because
of the conditional \r\n, you want:

^(((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}(\r?\n|$)){1,10}

-----Original Message-----
From: dagon [mailto:Click here to reveal e-mail address]
Sent: Sunday, November 04, 2001 01:26
To: aspngregexp
Subject: [aspngregexp] RE: help on regexp!

Basically,

^(((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}(\r?\n)?){1,10}$

-----Original Message-----
From: Matias Woloski [mailto:Click here to reveal e-mail address]
Sent: Sunday, November 04, 2001 00:16
To: aspngregexp
Subject: [aspngregexp] help on regexp!

Hi! I have to test some phones entered into a textarea. So for example
someone enter this:
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>
What I want to check is that the user enter a valid phone with this regex
((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}

but also I want to check that the number of phones entered to be <= 10
between phones there are Enters

so this is correct
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>

but this not
<textarea>
(123) 233222 <-- not valid phone
(124) 2334-1222
</textarea>

this is not correct
<textarea>
valid phone 1
valid phone 2
valid phone 3
valid phone 4
...
valid phone 10
valid phone 11 <-- there must be 10 phones only!
</textarea>

thanks in advance,
Matias

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Matias Woloski
that worked excelent!!! thanks dagon!
Do you have some tool to work with Reg Exps? (I saw a software Visual
RegExp, but it was for Linux)
thanks again!
Matias

-----Original Message-----
From: dagon [mailto:Click here to reveal e-mail address]
Sent: sábado, 03 de noviembre de 2001 20:43
To: aspngregexp
Subject: [aspngregexp] RE: help on regexp!

Oops, that would allow "(123) 2334-1222(123) 2334-1222" for example because
of the conditional \r\n, you want:

^(((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}(\r?\n|$)){1,10}

-----Original Message-----
From: dagon [mailto:Click here to reveal e-mail address]
Sent: Sunday, November 04, 2001 01:26
To: aspngregexp
Subject: [aspngregexp] RE: help on regexp!

Basically,

^(((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}(\r?\n)?){1,10}$

-----Original Message-----
From: Matias Woloski [mailto:Click here to reveal e-mail address]
Sent: Sunday, November 04, 2001 00:16
To: aspngregexp
Subject: [aspngregexp] help on regexp!

Hi! I have to test some phones entered into a textarea. So for example
someone enter this:
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>
What I want to check is that the user enter a valid phone with this regex
((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}

but also I want to check that the number of phones entered to be <= 10
between phones there are Enters

so this is correct
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>

but this not
<textarea>
(123) 233222 <-- not valid phone
(124) 2334-1222
</textarea>

this is not correct
<textarea>
valid phone 1
valid phone 2
valid phone 3
valid phone 4
...
valid phone 10
valid phone 11 <-- there must be 10 phones only!
</textarea>

thanks in advance,
Matias

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
    
Steven A Smith (VIP)
You can use http://regexlib.com/ which will let you search for and test
regular expressions.

Steve

Steven Smith
Click here to reveal e-mail address
President, ASPAlliance.com
http://aspalliance.com The #1 ASP.NET Community
http://aspsmith.com ASP.NET Training for ASP Developers

Get The Book: ASP.NET By Example
http://www.amazon.com/exec/obidos/ASIN/0789725622/stevenatorasp/
----- Original Message -----
From: "Matias Woloski" <Click here to reveal e-mail address>
To: "aspngregexp" <Click here to reveal e-mail address>
Sent: Sunday, November 04, 2001 9:44 PM
Subject: [aspngregexp] RE: help on regexp!

[Original message clipped]

Reply to this message...
 
    
dagon
Visual RegExp? That sounds terrible.. what do you do, drag and drop
expressions? :).

I don't work with any special tools for RegExps, I use my good old reliable
code editor, after a few years of RegExping that way it comes as natural as
any other piece of code.

Anyway, I'm glad it worked out for you and you're welcome :).

-----Original Message-----
From: Matias Woloski [mailto:Click here to reveal e-mail address]
Sent: Monday, November 05, 2001 04:45
To: aspngregexp
Subject: [aspngregexp] RE: help on regexp!

that worked excelent!!! thanks dagon!
Do you have some tool to work with Reg Exps? (I saw a software Visual
RegExp, but it was for Linux)
thanks again!
Matias

-----Original Message-----
From: dagon [mailto:Click here to reveal e-mail address]
Sent: sábado, 03 de noviembre de 2001 20:43
To: aspngregexp
Subject: [aspngregexp] RE: help on regexp!

Oops, that would allow "(123) 2334-1222(123) 2334-1222" for example because
of the conditional \r\n, you want:

^(((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}(\r?\n|$)){1,10}

-----Original Message-----
From: dagon [mailto:Click here to reveal e-mail address]
Sent: Sunday, November 04, 2001 01:26
To: aspngregexp
Subject: [aspngregexp] RE: help on regexp!

Basically,

^(((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}(\r?\n)?){1,10}$

-----Original Message-----
From: Matias Woloski [mailto:Click here to reveal e-mail address]
Sent: Sunday, November 04, 2001 00:16
To: aspngregexp
Subject: [aspngregexp] help on regexp!

Hi! I have to test some phones entered into a textarea. So for example
someone enter this:
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>
What I want to check is that the user enter a valid phone with this regex
((\(\d{3}\) ?)|(\d{3}-))?\d{4}-\d{4}

but also I want to check that the number of phones entered to be <= 10
between phones there are Enters

so this is correct
<textarea>
(123) 2334-1222
(124) 2334-1222
</textarea>

but this not
<textarea>
(123) 233222 <-- not valid phone
(124) 2334-1222
</textarea>

this is not correct
<textarea>
valid phone 1
valid phone 2
valid phone 3
valid phone 4
...
valid phone 10
valid phone 11 <-- there must be 10 phones only!
</textarea>

thanks in advance,
Matias

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

| [aspngregexp] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/aspngregexp.asp = JOIN/QUIT
| http://www.asplists.com/search = SEARCH Archives

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification