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: Beginner:
Removing empty spaces from a string

 



AndrewG
stranger

Jul 11, 2001, 11:38 AM

Post #1 of 4 (902 views)
Removing empty spaces from a string Can't Post

Say I have:

$name = "andrewxxxxxxxxxx"; (x = space)

How can I removed the empty space so that when I print it, it will just be 'andrew' and not 'andrewxxxxxxxxx'?

TIA



mhx
Enthusiast / Moderator

Jul 11, 2001, 11:51 AM

Post #2 of 4 (901 views)
Re: Removing empty spaces from a string [In reply to] Can't Post

Use the following regex search-and-replace pattern:

Code
$name =~ s/\s+$//;

Hope this helps.

-- Marcus



(This post was edited by mhx on Jul 11, 2001, 11:47 AM)


abstracts
Novice

Jul 11, 2001, 12:45 PM

Post #3 of 4 (899 views)
Re: Removing empty spaces from a string [In reply to] Can't Post

I guess you meant =~ not =;

Code
$name =~ s/\s+$//;

Aziz,,,



mhx
Enthusiast / Moderator

Jul 11, 2001, 12:47 PM

Post #4 of 4 (898 views)
Re: Removing empty spaces from a string [In reply to] Can't Post

Oooo, sure, sorry Crazy!

-- Marcus


 
 


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

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