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

Re: Re: Re: Re: Pattern Finding

by runrig (Abbot)
on Sep 13, 2001 at 21:12 UTC ( #112255=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Pattern Finding
in thread Pattern Finding

for the condition that one pattern cannot be part of another pattern

This is the toughest condition, and so I don't think it can be done with a regex, at least not with perl's regex engine (hope someone can prove me wrong :). At every stage of capuring a pattern, you'd have to be able to fail if the longer of the current pattern and each of all past patterns doesn't contain the other. Here's some psuedo perl regex code which, if it worked would accomplish this (hope you get the idea), but I'm using things in the wrong way, the regex engine isn't re-entrant, it uses "$1" instead of "\1" (and in a symbolic reference sort of way), etc, but I though it was interesting nonetheless. It would go right after each pattern caputure in my solution:

join('', map { "(?{(length($$i)>length($$_))$$i !~ /$$_/ | $$_ !~ /$$i/})" } 1..$_)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://112255]
help
Chatterbox?
[choroba]: I had 24.5 in January, but the last three month are below 18.5
[choroba]: and I'm trying hard not to get involved in troll feeding.

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2017-04-26 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (475 votes). Check out past polls.