[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 269
  • Last Modified:

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
0
countrymeister
Asked:
countrymeister
  • 4
  • 2
1 Solution
 
silemoneCommented:
ASC(.)*\.xls
0
 
ddrudikCommented:
0 or more:
^ASC[a-zA-Z]*\.xls$
1 or more:
^ASC[a-zA-Z]+\.xls$
0
 
silemoneCommented:
(ASC)[a-zA-Z]+\.xls...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Fernando SotoCommented:
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

Featured Post

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.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now