Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How do I replace a substring (if exists) with a different substring in a string?

by dkubb (Deacon)
on Jul 20, 2001 at 22:56 UTC ( [id://98499]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      my $string  = '01234567890';
      my $find    = '0';
    ...
        substr($string, $pos, length($find), $replace);
        $pos = index($string, $find, $pos + length($replace));
      }
    
  2. or download this
      $string =~ s/\Q$find\E/$replace/g;
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-03-29 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found