Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

How can a regex match every occurence of a string?

by Anonymous Monk
on Aug 25, 2000 at 14:23 UTC ( [id://29601]=perlquestion: print w/replies, xml ) Need Help??

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

$a="hi"; $b ="hello"; $c = "hibobhi"; $c=~ s/$a/$b/;
How can I make $c = "hellobobhello" not "hellobobhi"?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How can a regex match every occurence of a string?
by agoth (Chaplain) on Aug 25, 2000 at 15:17 UTC
    use /g; as your modifier.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 07:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found