Thursday, December 8, 2011

Ignore case partially

It's easy to ignore case of whole word in regular expression. But How do we do ignore case partially? For example, matching with AbcD, abcD, Abcd and abcd, but not matching ABCD, aBCd and so forth.

In the Japanese edition of "Regular Expressions Cookbook", there are two approaches.

mode toggle "i"

In the page #28, surround the word to ignore between (?i) and (?-i):

group with modifier "i"

In the page #76, use modifier "i" for the word to ignore:

No comments:

Post a Comment