p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   Perl (http://p2p.wrox.com/forumdisplay.php?f=196)
-   -   do a double perl replace in one line (http://p2p.wrox.com/showthread.php?t=55379)

crmpicco March 14th, 2007 11:13 AM

do a double perl replace in one line
 
Code:

$hotelreturned->{address} =~ s/<br>/ /g;
$hotelreturned->{address} =~ s/<br\/>/ /g;

is there a way to do this in a one-liner??

cheers, Picco

www.crmpicco.co.uk
www.ie7.com

crmpicco March 14th, 2007 11:16 AM

Code:

    $response =~ s/&lt;/</g;
    $response =~ s/&gt;/>/g;

kinda the same here......is it possible to do this on one line???


www.crmpicco.co.uk
www.ie7.com

crmpicco March 15th, 2007 08:55 AM

Code:

$hotelreturned->{address} =~ s/<br>/ /g;
$hotelreturned->{address} =~ s/<br\/>/ /g;
$hotelreturned->{address} =~ s/<br \/>/ /g;
$hotelreturned->{address} =~ s/\;//g;
$hotelreturned->{address} =~ s/\#//g;

can all this be put in a sub?

www.crmpicco.co.uk
www.ie7.com

ciderpunx March 16th, 2007 05:55 AM

Yeh, if you like. You could also condense it a bit

Code:

$hotelreturned->{address} =~ s/<br[\s\/]*>//g;
$hotelreturned->{address} =~ s/[\;\#]//g;

--
Charlie Harvey's website - linux, perl, java, anarchism and punk rock: http://charlieharvey.org.uk

crmpicco March 16th, 2007 08:53 AM

thanks chaz, does that definately replace semi-colons correctly? do i not need \; instead of ;

www.crmpicco.co.uk
www.ie7.com


All times are GMT -4. The time now is 03:59 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.