String::Gsub::Functions - core functions of String::Gsub


String-Gsub documentation  | view source Contained in the String-Gsub distribution.

Index


NAME

Top

String::Gsub::Functions - core functions of String::Gsub

SYNOPSIS

Top

 use String::Gsub::Functions qw(gsub);

 print gsub("abcabc", qr/(b)/,sub{uc$1}); # ==> "aBcaBc"

 gsubx(my $str = "abcabc", qr/(b)/, sub{uc $1});
 print $str; # ==> "aBcaBc";

DESCRIPTION

Top

This module has folloing functions:

 gsub ($str, $regexp, $replacement)
 gsubx($str, $regexp, $replacement)
 subs ($str, $regexp, $replacement)
 subsx($str, $regexp, $replacement)

$regexp is regular expression (qr//). And $replacement is code reference, which is invoked at replacement. In $replacement subroutine, match variables ($1, $2, ...) are avaiable like replacement part of s/PATTERN/REPLACEMENT/.

Both $regexp and $replacement can be string, but there are difference from usual part.

String passed on $regexp is not treated as regular expression , just string. special chars will be escaped.

String passwd on $replacement will be replaced some substrings with match strings and used as replacement string. \&, \` and \' are also did.

EXPORT

Top

This module can export gsub, gsubx, subs, subsx.

FUNCTIONS

Top

gsub($str, $regexp, $replacement)

process global substitute, and return new string.

gsubx($str, $regexp, $replacement)

like gsub, but replace self string and return itself.

subs($str, $regexp, $replacement)

process one substitute, and return new string.

subsx($str, $regexp, $replacement)

like subs, but replace self string and return itself.

SEE ALSO

Top

String::Gsub


String-Gsub documentation  | view source Contained in the String-Gsub distribution.