Rather than using a capture I think it might be simpler, since the OP mentions "end of a line" specifically, to just remove any non-pipe symbols anchored to the end of the string.
$ perl -Mstrict -Mwarnings -E ' my $str = q{RcdA|CON|139|||Kan|13|J|J|607|abc@gmail.com}; $str =~s{[^|]*$}{}; say $str;' RcdA|CON|139|||Kan|13|J|J|607| $
Cheers,
JohnGG
In reply to Re^2: how to remove a string from end of a line
by johngg
in thread how to remove a string from end of a line
by rpinnam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |