Re: regex and
On Tue, Aug 10, 2010 at 9:00 PM, wrote: > Once the & operator is in rakudo, though... I gather I /could/ do something > like the following > > ^ [ * & ] $ > > And this would in effect ensued that the sequence "abc" doesn't exist > anywhere across the match for > > > Is this correct? > Not quite, I suspect – the is still zero-width, so unless quantified zero-width assertions are DWIMmier than what's healthy, this is likely still equivalent to ^$. I think the following should DWYW, though: ^ [ [ . ] * & ] $ ... though perhaps there is a shorter way to write [ . ]? Feels like there should be one ... Eirik
RE: regex and
Back to your original advice... > If you want to match an alphabetic string which does not include 'abc' > anywhere, you can write this as > > ^ [ ]* $ I presume this only works here because is one character... if instead of I used anything more complicated (for example) token name { <[A..Z]>* } And then tried to do ^ [ ]* $ This wouldn't work since there's a wildcard within name. Once the & operator is in rakudo, though... I gather I /could/ do something like the following ^ [ * & ] $ And this would in effect ensued that the sequence "abc" doesn't exist anywhere across the match for Is this correct?
Re: regex and
philippe.beauch...@bell.ca wrote: > On the & operator... are you saying that it would operate basically as > expected... > allowing sets of rules and'ed rather than or's with the | ? Yes, with the limitation that both parts separated by & have to match the same length of string, so that for example ^ [ a+ & . ** 3 ] could only match exactly 3 a's. If you don't want to them tied to the same length, you look-ahead assertions instead. Cheers, Moritz
RE: regex and
Great! That does it. Thanks. :) I realized my error on the anchors after sending... but didn't think of the * on the grouping. On the & operator... are you saying that it would operate basically as expected... allowing sets of rules and'ed rather than or's with the | ? --- Phil -Original Message- From: Moritz Lenz [mailto:mor...@faui2k3.org] Sent: August 10, 2010 2:09 PM To: Beauchamp, Philippe (6009210) Cc: perl6-language@perl.org Subject: Re: regex and Hi, philippe.beauch...@bell.ca wrote: > rule TOP > { > ^ > [ > & * > & > ] > $ > } The & syntax is specced, but it's not yet implemented in Rakudo. But note that is a zero-width assertion, so your example regex matches at the start of a string, if it does not begin with 'abc'. Since you anchor it to the end of string too, it can only ever match the empty string. You can achieve the same with just ^$. If you want to match an alphabetic string which does not include 'abc' anywhere, you can write this as ^ [ ]* $ Cheers, Moritz
Re: regex and
Hi, philippe.beauch...@bell.ca wrote: > rule TOP > { > ^ > [ > & * > & > ] > $ > } The & syntax is specced, but it's not yet implemented in Rakudo. But note that is a zero-width assertion, so your example regex matches at the start of a string, if it does not begin with 'abc'. Since you anchor it to the end of string too, it can only ever match the empty string. You can achieve the same with just ^$. If you want to match an alphabetic string which does not include 'abc' anywhere, you can write this as ^ [ ]* $ Cheers, Moritz
regex and
Hi there... New to the list and getting to understand perl6 after a bit of a hiatis from the Perl world. I'm working my way through the new grammar syntax trying to implement some useful modules, and was wondering if there is a mechanism within the grammar constructs to allow two rules to apply simultaneously in parallel (not sequence). In other words... I want to say that for a rule to pass it must pass two contained rules completely. Ie: token abc { 'abc' } rule TOP { ^ [ & * & ] $ } Such that the TOP rule would only match if a matching string consisted entirely of alpha's AND did not contain the letter sequence "abc" anywhere in it. (*note I know the & notation isn't legit ;)
r31939 -[S32::IO] update to new type names, remove some thinkos
Author: moritz Date: 2010-08-10 14:55:57 +0200 (Tue, 10 Aug 2010) New Revision: 31939 Modified: docs/Perl6/Spec/S32-setting-library/IO.pod Log: [S32::IO] update to new type names, remove some thinkos Modified: docs/Perl6/Spec/S32-setting-library/IO.pod === --- docs/Perl6/Spec/S32-setting-library/IO.pod 2010-08-10 11:50:30 UTC (rev 31938) +++ docs/Perl6/Spec/S32-setting-library/IO.pod 2010-08-10 12:55:57 UTC (rev 31939) @@ -712,7 +712,7 @@ has Str $.Encoding; has Buf $.Binary; has IO::ACL @.ACLs; -has Hash of %.times; +has %.times; ... } @@ -723,9 +723,9 @@ all are checked before being pushed onto the array. Note that @.Elements can not be accessed unless $.Encoding is defined. -The C<%times> has keys that can be e.g. C, C, and +The C<%.times> has keys that can be e.g. C, C, and C (and maybe others on other operating systems), and the values are -all C objects. +all C objects. When a Path is used as a Str, it allows some operations, so that it can be concatenated easily with other strings. When used as an Array, it @@ -743,7 +743,7 @@ This is called automatically on object creation. multi method new( -Str|Buf :$Path, +Stringy :$Path, Str :@PathElements, Str :$Encoding,
perl6-language@perl.org
Author: masak Date: 2010-08-10 13:50:30 +0200 (Tue, 10 Aug 2010) New Revision: 31938 Modified: docs/Perl6/Spec/S32-setting-library/Str.pod Log: [S32/Str] nicer where clause for &pack Reads better and is more amenable to compiler optimization. Suggested by TheDamian++. Modified: docs/Perl6/Spec/S32-setting-library/Str.pod === --- docs/Perl6/Spec/S32-setting-library/Str.pod 2010-08-10 09:47:45 UTC (rev 31937) +++ docs/Perl6/Spec/S32-setting-library/Str.pod 2010-08-10 11:50:30 UTC (rev 31938) @@ -269,7 +269,7 @@ =item pack - our buf8 multi pack( *...@items where { [&&] @items »~~» Pair }) + our buf8 multi pack( *...@items where { all(@items) ~~ Pair } ) our buf8 multi pack( Str $template, *...@items ) C takes a list of pairs and formats the values according to
r31937 -[S32/Str] fixed thinko in &pack signature
Author: masak Date: 2010-08-10 11:47:45 +0200 (Tue, 10 Aug 2010) New Revision: 31937 Modified: docs/Perl6/Spec/S32-setting-library/Str.pod Log: [S32/Str] fixed thinko in &pack signature Spotted by moritz++ Modified: docs/Perl6/Spec/S32-setting-library/Str.pod === --- docs/Perl6/Spec/S32-setting-library/Str.pod 2010-08-09 22:37:35 UTC (rev 31936) +++ docs/Perl6/Spec/S32-setting-library/Str.pod 2010-08-10 09:47:45 UTC (rev 31937) @@ -269,7 +269,7 @@ =item pack - our buf8 multi pack( *...@items where { @items »~~» Pair }) + our buf8 multi pack( *...@items where { [&&] @items »~~» Pair }) our buf8 multi pack( Str $template, *...@items ) C takes a list of pairs and formats the values according to