An Introduction to Regular Expressions The Substitution Operator 31 of 50 : [PREV] [NEXT]

The Substitution Operator

Syntax

Perl supports another powerful operator, which performs substitutions in a string. The syntax of the Perl substitution operator is:

s/PATTERN/REPLACEMENT/egimosx

The substitution operator searches a string for PATTERN, and, if found, replaces the match (not the pattern, of course) with the REPLACEMENT text, and returns the number of substitutions made (this can be more than one if you use the /g modifier).


© 2003 Barbie barbie@missbarbell.co.uk Home http://birmingham.pm.org/