in reply to Re^2: How to remove underscore at the end of the line?
in thread How to remove underscore at the end of the line?

Just to drive davido's point home:

c:\@Work\Perl\monks>perl -wMstrict -le "for my $s (qw( DCMS_DEMO_ DCMS_DEMO_new_block2_ DCMS_DEMO_new_block2_checklist_tmp_ DCMS_DEMO_new_block2_checklist_tmp_rev1_ )) { my $subject = $s; print qq{'$subject'}; $subject =~ s/_(?=[^_]*$)//; print qq{'$subject' \n}; } " 'DCMS_DEMO_' 'DCMS_DEMO' 'DCMS_DEMO_new_block2_' 'DCMS_DEMO_new_block2' 'DCMS_DEMO_new_block2_checklist_tmp_' 'DCMS_DEMO_new_block2_checklist_tmp' 'DCMS_DEMO_new_block2_checklist_tmp_rev1_' 'DCMS_DEMO_new_block2_checklist_tmp_rev1'
That's with your original regex, and I get the same output with  s/_$// also.


Give a man a fish:  <%-{-{-{-<