I cant write 22 pipes like "\|.*\|.*".
Why not? ;-)
But try this:
I used your original example data and only removed four instances, not 22 (because there weren't that many), but you get the idea.c:\@Work\Perl\monks>perl -wMstrict -le "my $s = 'RcdA|CON|139|||Kan|13|J|J|607|abc@gmail.com'; print qq{'$s'}; ;; $s =~ s{ (?: [|] [^|]*){4} \z }{}xms; print qq{'$s'}; " 'RcdA|CON|139|||Kan|13|J|J|607|abc@gmail.com' 'RcdA|CON|139|||Kan|13'
Give a man a fish: <%-{-{-{-<
In reply to Re^5: how to remove a string from end of a line
by AnomalousMonk
in thread how to remove a string from end of a line
by rpinnam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |