Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: A NOT in regular expressions

by rruiz (Monk)
on May 14, 2003 at 02:56 UTC ( #257958=note: print w/replies, xml ) Need Help??


in reply to A NOT in regular expressions

You don't post your regular expression for us to take a look at it, but I think that you need to use the non greedy operator '?' in your re. Like:

#!/usr/bin/perl -wT use strict; my $s = 'stuff <% junk %> more stuff <% more junk %> end'; print "$s\n"; $s =~ s/<%.*?%>//g; print "$s\n";

Which makes the re to take the shortest match.

HTH
God bless you
rruiz

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://257958]
help
Chatterbox?
and a soft breeze sighs...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2018-06-18 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (110 votes). Check out past polls.

    Notices?