Regular Expressions Regex modifiers (flags) IGNORE CASE modifier


Example

The common modifier to ignore case is i:

/fog/i

will match Fog, foG, etc.

The inline version of the modifier looks like (?i).

Notes:

In Java, by default, case-insensitive matching assumes that only characters in the US-ASCII charset are being matched. Unicode-aware case-insensitive matching can be enabled by specifying the UNICODE_CASE flag in conjunction with this (CASE_INSENSITIVE) flag. (e.g. Pattern p = Pattern.compile("YOUR_REGEX", Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE);). Some more on this can be found at Case-Insensitive Matching in Java RegEx. Also, UNICODE_CHARACTER_CLASS can be used to make matching Unicode aware.