Regular Expression

I need to write a regular expression that matches the following string

the start of the string has ASC and then it could have any letters from a-zA-Z followed by .xls

example ASCRegions.xls , ASCfaculties.xls, ASCContracts.xls
LVL 1
countrymeisterAsked:
Who is Participating?
 
ddrudikConnect With a Mentor Commented:
0 or more:
^ASC[a-zA-Z]*\.xls$
1 or more:
^ASC[a-zA-Z]+\.xls$
0
 
silemoneCommented:
ASC(.)*\.xls
0
 
silemoneCommented:
(ASC)[a-zA-Z]+\.xls...
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Fernando SotoRetiredCommented:
Hi countrymeister,

This regex pattern should do it.

String pattern = @"(^ASC[a-zA-Z]+\.[xX][lL][sS])";

Regards,
Fernando
0
 
silemoneCommented:
my first submission:  takes into account all letters with (.)*, but also takes into account other characters such as numbers, etc...incase they are part of the name...

my second submission only takes into consideration and says there must be at least 1 character...and disreqard the '...'  its a habit...

also as ddrudik stated, I should have ^at the front and $ at the end...for beginning and end of line...
0
 
silemoneCommented:
well actually should be:

Regex reg = new Regex("^(ASC)[a-zA-Z]+\.xls$");

reg.Match("TextToCompare");
0
 
ddrudikCommented:
Thanks for the question and the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.