AbuMariam
AbuMariam

Reputation: 3678

Modifying a Regular Expression to be case insentsitve

I have the following reg exp...

[0-9]{6}\\-[A-Z]{4}_[0-9]{8}_[0-9]{6}_[a-zA-Z]{3}_(Web_)?[a-zA-Z0-9]{6}\\.[a-zA-Z0-9]{3,4}

It looks for a long file name with the word "Web" in it? However it is case-sensitive, meaning it catches the first of these Strings but not the second...

198284-QPYW_20130724_144810_ABC_Web_XNHVAS.mov
198284-QPYW_20130724_144810_ABC_web_XNHVAS.mov

Can anyone show me how I can tweak so it catches both of these?

Thanks.

Upvotes: 0

Views: 46

Answers (1)

Bryan Elliott
Bryan Elliott

Reputation: 4095

Depending on the regex engine you are using, you can just use a flag to make it case-insensitive. In most cases it's the i flag.

Otherwise in your regex, change the (Web_)? part to: ([Ww]eb_)?

So your full regex would be this:

\\-[A-Z]{4}_[0-9]{8}_[0-9]{6}_[a-zA-Z]{3}_([Ww]eb_)?[a-zA-Z0-9]{6}\\.[a-zA-Z0-9]{3,4}

Upvotes: 3

Related Questions