Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: removing a character from a string

by mrbbking (Hermit)
on Jun 18, 2002 at 19:49 UTC ( #175480=note: print w/ replies, xml ) Need Help??


in reply to removing a character from a string

Do like this:

my $string = '123-4567'; $string =~ s/-//g; print $string;
s/<search>/<replace>/g; # the 'g' replaces every occurrence of <search>, not just the first.

Update: This'll work, too:

my $i='123-4567'; my $j; while( length($i) ){ $j .= chop( $i ); chop $j if substr( $j, -1 ) eq '-'; } print reverse split //, $j;


Comment on Re: removing a character from a string
Select or Download Code
Replies are listed 'Best First'.
Re: Re: removing a character from a string
by bobothesmart (Initiate) on Jun 18, 2002 at 20:02 UTC
    Thanks :D

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://175480]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2015-08-30 00:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (346 votes), past polls