in reply to Re: Re: String Substitution Operator
in thread String Substitution Operator

If I provide a string like "14/01/52", I want the output to be : "14-01-52".
  • Comment on Re: Re: Re: String Substitution Operator

Replies are listed 'Best First'.
Re: Re: Re: Re: String Substitution Operator
by Roger (Parson) on Oct 23, 2003 at 09:01 UTC
    Simple.
    my $str = "14/01/52"; $str =~ s/\//-/g; # replace / with - print "$str\n";
Re: Re: Re: Re: String Substitution Operator
by Aragorn (Curate) on Oct 23, 2003 at 09:05 UTC
    By using $string =~ s!/!-!g. The exclamation points prevent the "toothpick syndrome" (s/\//-/g is a little less readable).

    Arjen