Link to home
Start Free TrialLog in
Avatar of countrymeister
countrymeister

asked on

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
Avatar of silemone
silemone
Flag of United States of America image

ASC(.)*\.xls
ASKER CERTIFIED SOLUTION
Avatar of ddrudik
ddrudik
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(ASC)[a-zA-Z]+\.xls...
Hi countrymeister,

This regex pattern should do it.

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

Regards,
Fernando
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...
well actually should be:

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

reg.Match("TextToCompare");
Thanks for the question and the points.