Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Removing 1 Charcter From String

by crackotter (Beadle)
on May 26, 2003 at 21:01 UTC ( [id://260890]=perlquestion: print w/replies, xml ) Need Help??

crackotter has asked for the wisdom of the Perl Monks concerning the following question:

What is the best way to remvoe a single charcter from a string? I want to remove the pound sign from a list of about 10,000. I do not want to change the strings in any other way.

Replies are listed 'Best First'.
Re: Removing 1 Charcter From String
by Limbic~Region (Chancellor) on May 26, 2003 at 21:05 UTC
    crackotter,
    If you want to get rid of all instances in the string:
    $string =~ tr/#//d;

    If you want to get rid of the first instance:
    $string =~ s/#//;

    If you want to get rid of a single instance somewhere else in the string - you will have to provide more information.

    Cheers - L~R

      Of course, if you're British:

      $string =~ tr/£//d;

      :-)

      If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
      That way everyone learns.

      Works awesome. Thank You -Otter

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://260890]
Approved by Paladin
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-16 23:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found