PROGRAMMING

 
REMEMBERS




Last update:   29-10-2021

About mode modifiers

Many flavors now allow some of the regex and match modes to be set. A common example is the special notation (?i). This turns on case-insensitive matching, and (?-i), which turns it off.
 
$text = "This is string";

$text =~ /([a-z]+)/; 

print $1 . "\n"; #Outputs: his
    
 
$text = "This is string";

$text =~ /((?i)[a-z]+)/; 

print $1 . "\n"; #Outputs: This
    
Common Mode Modifiers    (2/3)

Common mode modifiers

 
(?i)    case-insensitivity match mode

(?x)    free-spacing and comments regex mode

(?s)    dot-matches-all match mode

(?m)    enchanced line-anchor match mode
Mode & Parentheses    (3/3)

Mode & parentheses

A mode modifier turns on the mode only for what's matched within the parentheses.
 
$text = "This is string";

$text =~ /(?i:[a-z]+) ([a-z]+)/; 

print $1; #Outputs: is
    

Questions    
Atomic grouping

        A B C D E F
🔔
1/2