Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Using qr// with a complicated regex

by Chmrr (Vicar)
on Jul 12, 2002 at 21:29 UTC ( #181403=note: print w/replies, xml ) Need Help??

in reply to Using qr// with a complicated regex

I'll say right off that I've no hints as to what's causing your variables to get muched up. But though you havn't said all that much about your real data, but it seems like you're trying to make this much more complicated than it needs to be. For example, using a regex with lookahead in list context would seem to be the way to go when solving your example problem:

my @vars = $string =~ /\d(?=\w\d)/g;

Is there any particular reason why you need to do it using the japhy's twistiness? Any reason why you can't just get all \ds and pop the last one off, either?

perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Replies are listed 'Best First'.
Re: Re: Using qr// with a complicated regex
by elusion (Curate) on Jul 12, 2002 at 22:59 UTC
    Well my example problem is just an example that represents the basic problem. I don't have any foreknowledge of the regexes that will be used, because they're all generated dynamically from user input that's supposed to be as general as possible. I'm sure that most of the time I'd be safe with reshaping the regexes like this:
    my @vars; / (?: (\d) (?{ push @{ $vars[1] }, $1 }) \w )+ \d\w/x;
    But I want things to work under all possible cases. That's basically where things stand: I don't have a concrete example where it's necessary, but I don't want to not work when that situation comes up. I'll either try to live with the speed I have, (de|re)structure everything, or roll my own finite state machine.

    elusion :

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://181403]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2017-05-27 13:24 GMT
Find Nodes?
    Voting Booth?