Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
"be consistent"
 
PerlMonks  

How to replace the string within a string

by Anonymous Monk
on Feb 03, 2001 at 00:18 UTC ( [id://56175]=perlquestion: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.

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

I want to replace <P> in my string. I have to search for the <P> and replace it with space. Thanks

Title edit by tye, dropped a "g"

Replies are listed 'Best First'.
Re: How to replace the string withing a string
by MeowChow (Vicar) on Feb 03, 2001 at 00:20 UTC
    s/<P>/ /g
Re: How to replace the string withing a string
by coolmichael (Deacon) on Feb 03, 2001 at 21:02 UTC
    $_="I want to replace <P> in my string. I have to search for the <P> a +nd replace it with space. Thanks"; s/<P>/ /gi; print;
    results in:
    I want to replace in my string. I have to search for the and repla +ce it with space. Thanks
    update: You might also want to try perldoc perlre which explains regular expressions fairly well.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://56175]
Approved by root
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.