regex - How does pattern matching works using perl -
i have variables a:b:c a:b:d c:d:e
, need output displayed a-b a-b c-d
i try following code
$res="a:b:c a:b:d c:d:e"; $res=~s/\:/\-/g; $res=~s/..$//mgs; print "$res\n";
but did not receive output
use strict; use warnings; $res = "a:b:c a:b:d c:d:e"; $res =~ s{([a-z]):([a-z]):[a-z]}{$1-$2}ig;
Comments
Post a Comment