Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / October 2004

Tip: Looking for answers? Try searching our database.

Reg. exp. question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roy - 29 Oct 2004 19:00 GMT
Hi all,

I need to check a string for valid characters. The regular expression that I
am working is long and I try to make it short. There are many 'or' condition
in the expression, so if I can find answer to the following question then I
can make the reg exp shorter and nicer.
Now example: There is a word that could be 2 or 3 characters. First
characters should be "a" and the last character should be "d". The middle
character is either "n" or nothing. My regular expression looks like:
[a][n][d]|[a][d]
Is there a way to make the "d" optional as character d or nothing and not
use (|).
Thanks in advance,

Roy
Jacques Leclerc - 29 Oct 2004 20:07 GMT
Don't know if this will make it any shorter.
    an{0,1}d

{0,1} specifies that the expression will accept 0 or 1 occurances of the
preceding character or expression.

Hope this helps

Jacques

> Hi all,
>
[quoted text clipped - 11 lines]
>
> Roy

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.