Options for the S Operator : substitution « Regular Expression « Perl






Options for the S Operator

    
Option     Meaning
s/pattern/substitution/g     Replace all matches of pattern.
s/pattern/substitution/i     Ignore case in matching.
s/pattern/substitution/e     Evaluate substitution as an expression.
s/pattern/substitution/o     Compile expression only once.
s/pattern/substitution/m     Allow ^ to match after every newline and $ to match before every newline in the string being searched. 
s/pattern/substitution/s     Allows a period to match a newline.

   
    
    
    
  








Related examples in the same category

1.Options for the substitution operator.
2.Replace pattern
3.Replace pattern with ()
4.Substitute I with N and print
5.Substitute N with J
6.Substitute every T with M
7.Substitute first T with an M
8.Substitute first occurrence of "blue" with "red"
9.Substitute tom with Mary
10.Substitution Example
11.Substitution Modifiers
12.Using substitutions to clean up input data.
13.Capitalize all sentences
14.Using Patterns with Substitutions
15.Changing substitution delimiters
16.Increase salary with pattern match
17.Evaluate replacement
18.Alternation: /John|Karen|Steve/ will match a line containing John or Karen or Steve.
19.Ignore case, global substitution