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
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
ASC(.)*\.xls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(ASC)[a-zA-Z]+\.xls...
Hi countrymeister,
This regex pattern should do it.
String pattern = @"(^ASC[a-zA-Z]+\.[xX][lL] [sS])";
Regards,
Fernando
This regex pattern should do it.
String pattern = @"(^ASC[a-zA-Z]+\.[xX][lL]
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...
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]+\.xl s$");
reg.Match("TextToCompare") ;
Regex reg = new Regex("^(ASC)[a-zA-Z]+\.xl
reg.Match("TextToCompare")
Thanks for the question and the points.