in reply to Re: REGEX detailed character replace
in thread REGEX detailed character replace

s/\|//; s/\s+//g; my $c = 0; s/-/$c++ < 3 ? '-' : ','/eg;#Here pipe is not replaced by comma..Its just removing all pipes
s/^\|//; s/\s+//g; s/\|/\,/g my $c = 0; s/-/$c++ < 3 ? '-' : ','/eg;
This should work fine

Replies are listed 'Best First'.
Re^3: REGEX detailed character replace
by perlsaran (Sexton) on Nov 13, 2008 at 06:52 UTC
    We can also shrink further :)
    s/\|/$a++ < 1 ? '':','/eg;s/\s+//g;s/-/$c++ < 3 ? '-' : ','/eg;
      My goal wasn't to golf, but to provide a reasonable solution (as seen by my corruption of the OP's intent of "one line".) I don't think the extra complexity is warranted.