So, I'd go with the s/// solution.perl -Mre=debug -e '$_ = "foobar#2"; s/#[0-9]+$//' Compiling REx "#[0-9]+$" Final program: 1: EXACT <#> (3) 3: PLUS (15) 4: ANYOF[0-9][] (0) 15: EOL (16) 16: END (0) anchored "#" at 0 floating ""$ at 2..2147483647 (checking anchored) mi +nlen 2 Guessing start of match in sv for REx "#[0-9]+$" against "foobar#2" Found anchored substr "#" at offset 6... Found floating substr ""$ at offset 8... Starting position does not contradict /^/m... Guessed: match at offset 6 Matching REx "#[0-9]+$" against "#2" 6 <foobar> <#2> | 1:EXACT <#>(3) 7 <foobar#> <2> | 3:PLUS(15) ANYOF[0-9][] can match 1 times out o +f 2147483647... 8 <foobar#2> <> | 15: EOL(16) 8 <foobar#2> <> | 16: END(0) Match successful! Freeing REx: "#[0-9]+$"
In reply to Re^2: How do remove trailing data?
by JavaFan
in thread How do remove trailing data?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |