[sf-perl] Quick question on regular expression and substitution

Dan Lyke danlyke at flutterby.com
Wed Jun 28 12:13:58 PDT 2006


On Wed, 28 Jun 2006 09:19:15 -0700, Loo, Peter # PHX wrote:
> Would some one know of a one liner that would replace the third
> occurrence of a substring within a string?  For example:
> $string = "?, ?, ?, ?";

my $o = 2; # will replace the third "?"
$string =~ s/^((\?, ){$o})\?/$1 to_date(\?, xyz)/;



More information about the SanFrancisco-pm mailing list