CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
string manipulation

 



artperl
Novice

Sep 1, 2015, 6:02 AM

Post #1 of 3 (1571 views)
string manipulation Can't Post

dear perl gurus,

would like to consult on below.

say i have string below:

abcd efgh 1 (single space before digit)
ijkl mnop 2 (double space before digit)

what im trying to do is to remove the spaces & digit at the end.

I have below code but it only works for to take away 1 space for the second string above (1 space remains at the end). Is there a 1-liner to cater for both?

(my $new= $orig) =~ s/\ \d.*//;


FishMonger
Veteran / Moderator

Sep 1, 2015, 6:42 AM

Post #2 of 3 (1565 views)
Re: [artperl] string manipulation [In reply to] Can't Post

s/\s+\d$//


artperl
Novice

Sep 1, 2015, 6:46 AM

Post #3 of 3 (1563 views)
Re: [FishMonger] string manipulation [In reply to] Can't Post

works perfectly!!!... thanks much FishMonger!!!..., not to mention for the very quick advise!...

have a great day!...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives