Can you help me, how ignore case is working on Perl 5 regexps?
my $test = 'test';
$test ~~ s:perl5:i/E/OA/;
It gives me an error (replacing :i with :g, or just removing :i it works
well).
Bye,
Andras
Until :i is implemented, you can use
my $test = 'test';
$test ~~ s:perl5/(?i)E/OA/;
(?...) is standard perl5-way to place these flags into regexp.
--
Markus Laire
<Jam. 1:5-6>
`:i` is now implemented in r1963:
* :p5 allows as well as :perl5 for regex.
* allow arbitary adverb orders.
* :i / :ignorecase implemented.
* /x and /s semantics are enabled for p5 regex by default.
* "$" no longer matches "\n" at end of line by default.
As the default flags for :p5 is unspecified territory, I'd
welcome sanity-checking on the treatment above.
Thanks,
/Autrijus/
As this is my first post about pugs - all I can say is "wow." It is great to
already be coding perl6.
Thanks Autrijus and crew.
Paul
I'm inclined to agree.
Just as a heads up, I'm thinking of changing :perl5/:p5 to :Perl5/:P5
just to differentiate it from :parse/:p a little better..
: As this is my first post about pugs - all I can say is "wow." It is great to
: already be coding perl6.
I'm inclined to agree with that too. :-)
Larry
Okay. In that case, how about making Perl5ish adverbs work when :P5 is
specified? I have just checked in some code to make this work:
rx:P5:i:m:s:x:g/.../
Does it make sense to you?
> Just as a heads up, I'm thinking of changing :perl5/:p5 to :Perl5/:P5
> just to differentiate it from :parse/:p a little better..
Okay, currently I'm allowing all four forms then.
> : As this is my first post about pugs - all I can say is "wow." It is
> : great to already be coding perl6.
>
> I'm inclined to agree with that too. :-)
Thanks. :-)
/Autrijus/
That means that we either have to have an order dependency or be
very careful not to allow any P6 shortcuts that happen to use the
deprecated Perl 5 modifiers. Perhaps it would be better to have an
option argument to P5 instead:
rx:P5('imsxg')/.../
or some such. Given the current bias towards adverbs slurping up the
following postfix brackets, that could perhaps also be written:
rx:P5<imsxg>/.../
But that does mean you have to write
rx:P5 <...>
rather than
rx:P5<...>
if you want to use brackets for delimiters. Nevertheless, the rule
seems to simplify things, and with a backtracking token parser it's a
simple mistake to check for and give a decent error message on in most
cases. I expect people will simply get used to writing all ambiguously
bracketed quote constructs with spaces, as in q:foo:bar (...). But we
have to allow arguments to adverbs somehow, and restricting them to ()
seems awfully limiting, and I don't really want to have two different
classes of adverbs. [Extended discussion to p6l please.]
I'd just note that
rx<...>
is still perfectly acceptable, since there are no adverbs slurping up
an argument.
Larry
Cool, I like that! Implemented as r1975:
* P5 flags are now spelled as :P5<imsgx>. :i :g works too.
Thanks,
/Autrijus/