Re: Need regex ^? help

2024-05-06 Thread ToddAndMargo via perl6-users
This is what I have so far. my $x=" 1.2.3.4:12345 "; $x = $x.trim; $x~~s/(.*'.') .*/$0$(Q[0/24])/; say "<$x>"; <1.2.3.0/24> It works. Is there a way to petty it up with ^ and $ ?

Re: Need regex ^? help

2024-04-29 Thread ToddAndMargo via perl6-users
On 4/29/24 17:57, Patrick R. Michaud wrote: Perhaps not really what you're intending, but here's how I'd start: $ raku -e 'my $x="1.2.3.4"; $x ~~ s!\d+$!0/24!; say $x;' 1.2.3.0/24 The pattern part of the substitution matches all of the digits at the end of the string (\d+$), then

Re: Need regex ^? help

2024-04-29 Thread Patrick R. Michaud
Perhaps not really what you're intending, but here's how I'd start: $ raku -e 'my $x="1.2.3.4"; $x ~~ s!\d+$!0/24!; say $x;' 1.2.3.0/24 The pattern part of the substitution matches all of the digits at the end of the string (\d+$), then replaces them with the string "0/24". Everything

Re: Need regex ^? help

2024-04-29 Thread ToddAndMargo via perl6-users
On 4/29/24 17:42, ToddAndMargo via perl6-users wrote: Hi All, I thought I understood ^ and ? used in a regex'es, but I don't. ^ means from the beginning and ? from the end. I am trying to put together an example of how to use them: I have    1.2.3.4 I want    1.2.3.0/24 So Far I have

Need regex ^? help

2024-04-29 Thread ToddAndMargo via perl6-users
Hi All, I thought I understood ^ and ? used in a regex'es, but I don't. ^ means from the beginning and ? from the end. I am trying to put together an example of how to use them: I have 1.2.3.4 I want 1.2.3.0/24 So Far I have (not working): raku -e 'my $x="1.2.3.4"; $x~~s/ (.*)

Re: Need regex help

2018-09-16 Thread ToddAndMargo
On 09/15/2018 07:32 PM, Larry Wall wrote: On Sat, Sep 15, 2018 at 06:45:33PM -0700, ToddAndMargo wrote: : Hi All, : : I have been doing a bunch with regex's lately. : I just throw them out based on prior experience : and they most all work now. I only sometimes have to : ask for help. (The

Re: Need regex help

2018-09-15 Thread Larry Wall
On Sat, Sep 15, 2018 at 06:45:33PM -0700, ToddAndMargo wrote: : Hi All, : : I have been doing a bunch with regex's lately. : I just throw them out based on prior experience : and they most all work now. I only sometimes have to : ask for help. (The look forward () feature : is sweet.) : :

Need regex help

2018-09-15 Thread ToddAndMargo
Hi All, I have been doing a bunch with regex's lately. I just throw them out based on prior experience and they most all work now. I only sometimes have to ask for help. (The look forward () feature is sweet.) Anyway, I have been using regex switches without knowing why. So What is the

Re: need regex help

2018-08-05 Thread ToddAndMargo
On 08/02/2018 09:43 AM, Arthur Ramos Jr. wrote: This works too: my $x = "9.0v1"; die "Horribly" if $x =~ /[\p{L}]+/; Art Perl 5 by chance (=~)? Or am I missing something?

Re: need regex help

2018-08-05 Thread Curt Tilmes
On Thu, Aug 2, 2018 at 8:18 AM Timo Paulssen wrote: > Is this what you want? > > perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/' > 「12345」 > > perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/' > Nil On Sun, Aug 5, 2018 at 6:41 PM Arthur Ramos Jr. wrote: > my $x = "9.0v1"; die "Horribly" if $x

Re: need regex help

2018-08-05 Thread Arthur Ramos Jr.
This works too: my $x = "9.0v1"; die "Horribly" if $x =~ /[\p{L}]+/; Art On Thu, Aug 2, 2018 at 8:18 AM Timo Paulssen wrote: > Is this what you want? > > perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/' > 「12345」 > > perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/' > Nil > > HTH > - Timo >

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/03/2018 11:36 AM, Parrot Raiser wrote: If I've interpreted this https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_ranges correctly, ^ is "start of string" +alnum means "in the alphanumeric set" -alpha means "not in the purely alphabetic set" i.e. <+alnum -alpha>

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/03/2018 11:52 AM, Patrick R. Michaud wrote: The + essentially indicates that this is a character-class match. It's to distinguish things from <.alpha>, , , <-alpha>, and (among others). Thank you!

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/03/2018 11:48 AM, Timo Paulssen wrote: The + is required, perhaps because the first character after the opening < is supposed to determine exactly what thing it is? Not sure about that. The + and - is a bit like "start at nothing, add all alnums, then subtract all alphas". The + after the

Re: need regex help

2018-08-03 Thread Patrick R. Michaud
The + essentially indicates that this is a character-class match. It's to distinguish things from <.alpha>, , , <-alpha>, and (among others). Pm On Fri, Aug 03, 2018 at 08:48:24PM +0200, Timo Paulssen wrote: > The + is required, perhaps because the first character after the opening > < is

Re: need regex help

2018-08-03 Thread Timo Paulssen
The + is required, perhaps because the first character after the opening < is supposed to determine exactly what thing it is? Not sure about that. The + and - is a bit like "start at nothing, add all alnums, then subtract all alphas". The + after the < > is just to match it any number of times,

Re: need regex help

2018-08-03 Thread Brandon Allbery
That document also says that _ is considered a letter (that is, is matched by : https://docs.perl6.org/language/regexes#Predefined_Character_Classes), so that's the same thing as . I observed that earlier as well. On Fri, Aug 3, 2018 at 2:37 PM Parrot Raiser <1parr...@gmail.com> wrote: > If I've

Re: need regex help

2018-08-03 Thread Parrot Raiser
If I've interpreted this https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_ranges correctly, ^ is "start of string" +alnum means "in the alphanumeric set" -alpha means "not in the purely alphabetic set" i.e. <+alnum -alpha> means "alphanumeric but not a letter", i.e 0-9_

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/02/2018 05:18 AM, Timo Paulssen wrote: Is this what you want? perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/' 「12345」 perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/' Nil HTH   - Timo What does the following do? +alnum (why does it need the "+"?) -alpha (I presume "-"

Re: need regex help

2018-08-03 Thread ToddAndMargo
On 08/02/2018 05:18 AM, Timo Paulssen wrote: Is this what you want? perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/' 「12345」 perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/' Nil HTH   - Timo A piece of art. Thank you!

Re: need regex help

2018-08-02 Thread Timo Paulssen
Is this what you want? perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/' 「12345」 perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/' Nil HTH   - Timo

Re: need regex help

2018-08-02 Thread Laurent Rosenfeld via perl6-users
Set operations seem to be unsupported on predefined character classes (or subrules). (Or, if they are supported, I don't know what the right syntax might be.) Set operations seem to work properly, though, with escaped character classes. For example: perl6 -e 'my $x = "9.0v1"; say so $x ~~ /<[\w]

Re: need regex help

2018-08-02 Thread Paul Procacci
\d and both match Unicode characters as well. If that's not the intention then it's best to be explicit. die("Horribly") unless "9.b1" ~~ / <[0-9]+> % '.' /; Typing from my phone so unable to test the above*** On Thu, Aug 2, 2018, 12:56 AM ToddAndMargo wrote: > Hi All, > > If there are any

Re: need regex help

2018-08-01 Thread ToddAndMargo
On 08/01/2018 10:00 PM, Brandon Allbery wrote: Set operations have to be inside the <>. You want something like: /<[alnum-alpha]>/. That said, this would be the same as //, I think? Please describe in words what you intended with that regex. (I suspect /<[alpha]>/ is what you really want,

Re: need regex help

2018-08-01 Thread Brandon Allbery
Set operations have to be inside the <>. You want something like: /<[alnum-alpha]>/. That said, this would be the same as //, I think? Please describe in words what you intended with that regex. (I suspect /<[alpha]>/ is what you really want, based on your earlier statement.) On Thu, Aug 2, 2018

need regex help

2018-08-01 Thread ToddAndMargo
Hi All, If there are any letter in the string, I want it to fail $ p6 'my $x="9.0v1"; if $x~~/<+alnum>-[]>/ {say "Y";}' ===SORRY!=== Unrecognized regex metacharacter - (must be quoted to match literally) at -e:1 --> my $x="9.0v1"; if $x~~/<+alnum>⏏-[]>/ {say "Y";} Unable to parse regex;

Re: I need regex help

2018-05-11 Thread ToddAndMargo
On 05/11/2018 02:03 AM, Steve Mynott wrote: There is a perl 5 compatible option you can pass to perl 6 regexps. Not sure its 100% and I think it's based on perl5.10 but it could be useful if you wanted to gradually port perl 5 to perl 6. I am going to figure it out if it kills me!

Re: I need regex help

2018-05-10 Thread ToddAndMargo
On 05/10/2018 09:26 PM, ToddAndMargo wrote: On 05/10/2018 09:13 PM, ToddAndMargo wrote: On Thu, May 10, 2018 at 11:56 PM, ToddAndMargo > wrote:     Hi All,     I am trying to convert this over from Perl5:     P5:     $dir_entry  =~

Re: I need regex help

2018-05-10 Thread ToddAndMargo
On 05/10/2018 09:13 PM, ToddAndMargo wrote: On Thu, May 10, 2018 at 11:56 PM, ToddAndMargo > wrote:     Hi All,     I am trying to convert this over from Perl5:     P5:     $dir_entry  =~ /.*?(\d{1,4}\D\d{1,4}\D\d{1,4}).*${Extension}/;

Re: I need regex help

2018-05-10 Thread ToddAndMargo
On Thu, May 10, 2018 at 11:56 PM, ToddAndMargo > wrote: Hi All, I am trying to convert this over from Perl5: P5: $dir_entry =~ /.*?(\d{1,4}\D\d{1,4}\D\d{1,4}).*${Extension}/; P6: $dir_entry ~~

Re: I need regex help

2018-05-10 Thread Brandon Allbery
Pretty much what it's telling you. Instead of the numbers in braces, it's the ** operator with a range after it: \d ** 1..4 (Remember that spaces do nothing in a P6 regex, so you can use them for readability or to separate the range from what follows, etc.) On Thu, May 10, 2018 at 11:56 PM,

I need regex help

2018-05-10 Thread ToddAndMargo
Hi All, I am trying to convert this over from Perl5: P5: $dir_entry =~ /.*?(\d{1,4}\D\d{1,4}\D\d{1,4}).*${Extension}/; P6: $dir_entry ~~ m/.*?(\d{1,4}\D\d{1,4}\D\d{1,4}).*{$Extension}/; $ perl6 -c GetUpdates.pl6 ===SORRY!=== Unsupported use of {N,M} as general quantifier; in Perl 6