Search notes:

Regular expressions: case sensitivity

Some regular expression dialects (which ones?) allow to explicitly turn on or off case sensitivity in the pattern itself with (?i) or (?-i).

PowerShell example

The following PowerShell example tries to demonstrate the usage of (?) an (?-i).
$regex_case_default    = [regex]::new(     'ab*c')
$regex_case_insensitiv = [regex]::new( '(?i)ab*c')
$regex_case_sensitiv   = [regex]::new('(?-i)ab*c')

$regex_case_default.match(   'xAcd').success # False
$regex_case_insensitiv.match('xAcd').success # True
$regex_case_sensitiv.match(  'xAcd').success # False
See also the System.Text.RegularExpressions.RegexOptions enum.

Index