Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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


Comment on Re: A NOT in regular expressions
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (12)
As of 2015-07-07 00:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (85 votes), past polls