Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: simple regexp question

by andreas1234567 (Vicar)
on Nov 21, 2007 at 09:38 UTC ( [id://652087]=note: print w/replies, xml ) Need Help??


in reply to simple regexp question

Something like this perhaps?
$ perl -w use strict; my $str = q{sometext with conetnst add kklkk&dfaf:dfaÜÄmlddö;}; $str =~ s/&(.*?);/&$1 ;/g; print $str; __END__ sometext with conetnst add kklkk&dfaf:dfaÜÄmlddö ;
Update: Thanks to johngg for identifying glitch.
--
Andreas

Replies are listed 'Best First'.
Re^2: simple regexp question
by johngg (Canon) on Nov 21, 2007 at 09:49 UTC
    Did you mean

    $str =~ s/&(.*?);/&$1 ;/g;

    perhaps? Your code as it stands seems to lose the text after the ampersand.

    Cheers,

    JohnGG

Re^2: simple regexp question
by Punitha (Priest) on Nov 21, 2007 at 10:57 UTC

    In customising the andreas1234567 code, you can use it as

    use strict; my $str = q{sometext with conetnst add kklkk&dfaf:dfaÜÄmlddö;}; $str =~ s/&([^;]+);/&$1 ;/g; #This includes all the characters til +l the semicolon print $str;

    Punitha

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-24 11:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found