.NETGURU
Regular Expressions
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngfreeforall' 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.

Scott A. Mahler
=20

Hi all,
I'm using VS 7 and in a regular expression validator control, there is a
mask for U.S. Phone #
((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
=20
As a regular expression novice, I want to change this to make the
Parenthesis around the area code optional
=20
How would I do it.
=20
=20
Thanks
=20
Scott

Reply to this message...
 
    
Ryan Trudelle-Schwarz (VIP)
Parens are carroted in the following:
((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
^^ ^^
(the reason why I carroted the "\" as well is that you have to escape
the "(" and ")")
So to make them optional put a "?" after them:
((\(?\d{3}\)? ?)|(\d{3}-))?\d{3}-\d{4}

Hth, Ryan

:: -----Original Message-----
:: From: Scott A. Mahler [mailto:Click here to reveal e-mail address]
::
:: Hi all,
:: I'm using VS 7 and in a regular expression validator
:: control, there is a mask for U.S. Phone #
:: ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
::
:: As a regular expression novice, I want to change this to
:: make the Parenthesis around the area code optional
::
:: How would I do it.
::
::
:: Thanks
::
:: Scott

Reply to this message...
 
    
Scott A. Mahler
Yes it does thanks

-----Original Message-----
From: Ryan Trudelle-Schwarz [mailto:Click here to reveal e-mail address]
Sent: Wednesday, December 19, 2001 7:27 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: Regular Expressions

Parens are carroted in the following:
((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
^^ ^^
(the reason why I carroted the "\" as well is that you have to escape
the "(" and ")")
So to make them optional put a "?" after them:
((\(?\d{3}\)? ?)|(\d{3}-))?\d{3}-\d{4}

Hth, Ryan
=20
:: -----Original Message-----
:: From: Scott A. Mahler [mailto:Click here to reveal e-mail address]=20
::=20
:: Hi all,
:: I'm using VS 7 and in a regular expression validator=20
:: control, there is a mask for U.S. Phone #
:: ((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}
:: =20
:: As a regular expression novice, I want to change this to=20
:: make the Parenthesis around the area code optional
:: =20
:: How would I do it.
:: =20
:: =20
:: Thanks
:: =20
:: Scott

| ASP.net DOCS =3D http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/aspngfreeforall =3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP

Reply to this message...
 
    
Steven A Smith (VIP)
You might also check out some of the ones available at http://regexlib.com,
and consider adding this one if it isn't already there.

Steve

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>
To: "aspngfreeforall" <Click here to reveal e-mail address>
Sent: Wednesday, December 19, 2001 10:26 PM
Subject: [aspngfreeforall] RE: Regular Expressions

[Original message clipped]

Reply to this message...
 
    
Alex Lowe
Just so everyone is aware, there is a regular expression list
[aspngregexp] (http://aspfriends.com/aspfriends/aspngregexp.asp) where
regular expression experts hang out.

Alex - AspFriends.com Moderation Team

ASP.NET Tips/Examples: http://aspalliance.com/aldotnet

-----Original Message-----
From: Steven A Smith [mailto:Click here to reveal e-mail address]
Sent: Wednesday, December 19, 2001 9:50 PM
To: aspngfreeforall
Subject: [aspngfreeforall] RE: Regular Expressions

You might also check out some of the ones available at
http://regexlib.com, and consider adding this one if it isn't already
there.

Steve

----- Original Message -----
From: "Ryan Trudelle-Schwarz" <Click here to reveal e-mail address>
To: "aspngfreeforall" <Click here to reveal e-mail address>
Sent: Wednesday, December 19, 2001 10:26 PM
Subject: [aspngfreeforall] RE: Regular Expressions

[Original message clipped]

| ASP.net DOCS = http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/aspngfreeforall = JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP

Reply to this message...
 
    
Administrator
Does anyone know a good site that has regex samples? I used to know of =
one that had a ton of samples, but my computer died and took the url =
with it.

Thanks,

John

Reply to this message...
 
    
Brian Bilbro (VIP)
http://regxlib.com/
has a bunch of regular expressions.

--
Brian

----- Original Message -----
From: "Administrator" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Sat, 27 Jul 2002 20:10:03 -0700
Subject: Regular Expressions
[Original message clipped]

with it.
[Original message clipped]

Reply to this message...
 
    
Moores, Ian
Using the :

System.Text.RegularExpressions.Regex.Match(string, exp)

I need to get the name of a folder out from a string... i.e i have got
"/foldername/filename.aspx"

I need to get just the foldername out... what is the regular expression
that does this?

Thanks as always

Ian Moores

Web Developer / WebMaster

iRevolution Ltd

+44 (0)1895 425 789 Direct

+44 (0)1895 444 420 Tel

+44 (0)1895 444 460 Fax
Reply to this message...
 
    
mrpike
Alreet Ian

Dim folder_Name as String
Dim Regexp as Regex =3D new =
Regex("/filename.aspx",RegexOptions.IgnoreCase)
                 folder_Name =3D =
regexp.Replace(request.ServerVariables("PATH_INFO"),"")

should work.
Works for me on http://www.travelcounsellors.com/jeff.calderbank etc.

Cheers
Damian

----- Original Message -----
From: "Moores, Ian" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Thu, 8 Aug 2002 11:57:19 +0100
Subject: regular expressions
[Original message clipped]

Reply to this message...
 
    
Alex Lowe
We have a list - [aspngregexp]
(http://aspfriends.com/aspfriends/aspngregexp.asp) - where regular
expression experts hang out. I suggest you take the thread there for
more assistance if need be.

Regards,

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

Reply to this message...
 
    
Ron Novendstern
Take me off your list, please
----- Original Message -----
From: "mrpike" <Click here to reveal e-mail address>
To: "aspngfreeforall" <Click here to reveal e-mail address>
Sent: Thursday, August 08, 2002 7:46 AM
Subject: [aspngfreeforall] Re: regular expressions

Alreet Ian

Dim folder_Name as String
Dim Regexp as Regex = new Regex("/filename.aspx",RegexOptions.IgnoreCase)
folder_Name = regexp.Replace(request.ServerVariables("PATH_INFO"),"")

should work.
Works for me on http://www.travelcounsellors.com/jeff.calderbank etc.

Cheers
Damian

----- Original Message -----
From: "Moores, Ian" <Click here to reveal e-mail address>
To: Click here to reveal e-mail address
Sent: Thu, 8 Aug 2002 11:57:19 +0100
Subject: regular expressions
[Original message clipped]

| ASP.net DOCS = http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/aspngfreeforall = JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP

Reply to this message...
 
    
Feduke Cntr Charles R
Ian,

    Wouldn't System.IO.Path.GetDirectoryName(string) fit the bill? And
if you just need the last folder, use a .Substring with
.LastIndexOf(System.IO.Path.DirectorySeparatorChar).

- Chuck

-----Original Message-----
From: Alex Lowe [mailto:Click here to reveal e-mail address]
Sent: Thursday, August 08, 2002 7:52 AM
To: aspngfreeforall
Subject: [aspngfreeforall] Re: regular expressions

We have a list - [aspngregexp]
(http://aspfriends.com/aspfriends/aspngregexp.asp) - where regular
expression experts hang out. I suggest you take the thread there for
more assistance if need be.

Regards,

Alex - AspFriends.com Moderation Team
Microsoft MVP - ASP.NET

***********************************************************
Translate C# code to VB.NET code at
http://aspalliance.com/aldotnet/examples/translate.aspx
***********************************************************

[Original message clipped]

| ASP.net DOCS = http://www.aspng.com/docs
| [aspngfreeforall] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/aspngfreeforall = JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP

Reply to this message...
 
 
System.IO.Path
System.Text.RegularExpressions.Regex
System.Text.RegularExpressions.RegexOptions




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