Matching mixed up words

T

Tassilo v. Parseval

Also sprach Abigail:
Tassilo v. Parseval ([email protected]) wrote on
MMMMCCXLV September MCMXCIII in <URL:()
() Indeed, this is much better. Interestingly enough, it stops working when
() using split:
()
() use strict;
() use warnings;
() no warnings qw /syntax/;
()
() my $word = "gremlin";
() my $ana = "nlmregi";
()
() my (%h);
() print $word =~ m#
() ^(?{%h = ()})
() (?{$h {$_} ++ for split //, $ana})
() (?: (.) (?(?{$h {$1} --> 0})|(?!)) )*
() $(?(?{grep {$_} values %h})(?!)|)#x
() ? "match\n" : "no match\n";
()
() As far as I see it, this code should be functionally equivalent to
() yours. Probably these extended patterns don't work too well when another
() pattern match happens inside.


The regex engine is not re-entrant. So you can't use split inside
a regex.

I guess this the case. Yet, I wonder why perl lets me do it. It could
easily barf when it encounters anything that requires re-entrantness
in (?{}) and (??{}).
(And # is a nasty delimiter to use in combination with /x).

Next to /, it's my default-delimiter. As I virtually never use /x, I
seldom question its use. :)

Tassilo
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top