RegEx: How to check for Case in pattern?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Niroj@Work
Pro Scripter
Posts: 63
Joined: Thu Dec 10, 2009 8:13 am

RegEx: How to check for Case in pattern?

Post by Niroj@Work » Mon Jun 14, 2010 6:36 am

How to check proper case in a pattern using RegEx?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jun 14, 2010 9:15 am

This modifier turns off case insensitive (makes the matching case sensitive):

(?-i)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Niroj@Work
Pro Scripter
Posts: 63
Joined: Thu Dec 10, 2009 8:13 am

example

Post by Niroj@Work » Thu Jun 17, 2010 5:07 am

Could you please provide one example?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jun 17, 2010 9:18 am

Consider the following:

Code: Select all

Let>pattern=(?-i)M\d*
Let>text=M1234m234M5555m43
RegEx>pattern,text,0,matches,nm,0
This will match and return only M1234 and M5555

If you change it to:

Code: Select all

Let>pattern=M\d*
Let>text=M1234m234M5555m43
RegEx>pattern,text,0,matches,nm,0
Then it will return all matches M1234, m234, M5555 and m43
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts