[pugs] regexp ignore case

6 views
Skip to first unread message

BÁRTHÁZI András

unread,
Apr 14, 2005, 3:38:42 AM4/14/05
to perl6-c...@perl.org
Hi,

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

Markus Laire

unread,
Apr 14, 2005, 6:07:32 AM4/14/05
to BÁRTHÁZI András, perl6-c...@perl.org

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>

Autrijus Tang

unread,
Apr 14, 2005, 9:36:14 AM4/14/05
to Markus Laire, BÁRTHÁZI András, perl6-c...@perl.org
On Thu, Apr 14, 2005 at 01:07:32PM +0300, Markus Laire wrote:
> Until :i is implemented, you can use

`: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/

Paul Seamons

unread,
Apr 14, 2005, 10:58:47 AM4/14/05
to perl6-c...@perl.org
I would think that :p5 should behave as perl5 does by default. That would
mean that /x and /s aren't on by default (for p5).

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

Larry Wall

unread,
Apr 14, 2005, 12:51:27 PM4/14/05
to perl6-c...@perl.org
On Thu, Apr 14, 2005 at 08:58:47AM -0600, Paul Seamons wrote:
: I would think that :p5 should behave as perl5 does by default. That would
: mean that /x and /s aren't on by default (for p5).

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

Autrijus Tang

unread,
Apr 14, 2005, 1:25:24 PM4/14/05
to perl6-c...@perl.org
On Thu, Apr 14, 2005 at 09:51:27AM -0700, Larry Wall wrote:
> On Thu, Apr 14, 2005 at 08:58:47AM -0600, Paul Seamons wrote:
> : I would think that :p5 should behave as perl5 does by default. That would
> : mean that /x and /s aren't on by default (for p5).
>
> I'm inclined to agree.

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/

Larry Wall

unread,
Apr 14, 2005, 2:03:56 PM4/14/05
to perl6-c...@perl.org
On Fri, Apr 15, 2005 at 01:25:24AM +0800, Autrijus Tang wrote:
: 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?

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

Autrijus Tang

unread,
Apr 14, 2005, 2:18:40 PM4/14/05
to perl6-c...@perl.org
On Thu, Apr 14, 2005 at 11:03:56AM -0700, Larry Wall wrote:
> 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>/.../

Cool, I like that! Implemented as r1975:

* P5 flags are now spelled as :P5<imsgx>. :i :g works too.

Thanks,
/Autrijus/

Reply all
Reply to author
Forward
0 new messages