Need match character help

Hi All,

This should be a "no".  What am I doing wrong?

$ perl6 -e 'my $x="rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say "yes"}else{say 
"no"}'
yes


Many thanks,
-T
0
ToddAndMargo
5/15/2018 11:49:14 AM
perl.perl6.users 1023 articles. 0 followers. Follow

26 Replies
50 Views

Similar Articles

[PageSpeed] 58

On 05/15/2018 04:49 AM, ToddAndMargo wrote:
> Hi All,
>=20
> This should be a "no".=C2=A0 What am I doing wrong?
>=20
> $ perl6 -e 'my $x=3D"rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say "yes"}else{s=
ay=20
> "no"}'
> yes
>=20
>=20
> Many thanks,
> -T

And how do I turn this into a yes.  I am look for
any instance of d through z

$ perl6 -e 'my $x=3D"f"; if $x~~/<[d.z]>/ {say "yes"}else{say "no"}'
no
0
ToddAndMargo
5/15/2018 12:03:40 PM
On 15/05/18 13:49, ToddAndMargo wrote:
> Hi All,
>
> This should be a "no".=C2=A0 What am I doing wrong?
>
> $ perl6 -e 'my $x=3D"rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
> "yes"}else{say "no"}'
> yes
>
>
> Many thanks,
> -T

what you've put in your regex here is a character class combined of four
individual ones "added together";

it matches a single letter that is either an "r", a "c", an "a", a "b",
or a ".". Character classes always match only a single character, if you
want it to match more, you will have to use a quantifier, like "+", "*",
or "**". Since your regex is not anchored, it will accept any of those
characters in any spot, so strings like "hello a" will match, too.

It seems like what you want is actually this:

/rc | a | b | "."/

which matches if either "rc", "a", "b" or "." exist somewhere in the stri=
ng.

If you want to accept only if the full string is "rc", "a", "b" or ".",
you'll have to put anchors in the front and back, and put brackets
around the inner part, so that the ^ and $ refer to the whole
alternation, not just the ^ to the first variant and $ to the last varian=
t.
0
timo
5/15/2018 2:05:04 PM
On 15/05/18 14:03, ToddAndMargo wrote:
> On 05/15/2018 04:49 AM, ToddAndMargo wrote:
>> Hi All,
>>
>> This should be a "no".=C2=A0 What am I doing wrong?
>>
>> $ perl6 -e 'my $x=3D"rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
>> "yes"}else{say "no"}'
>> yes
>>
>>
>> Many thanks,
>> -T
>
> And how do I turn this into a yes.=C2=A0 I am look for
> any instance of d through z
>
> $ perl6 -e 'my $x=3D"f"; if $x~~/<[d.z]>/ {say "yes"}else{say "no"}'
> no

The syntax you're looking for is <[d..z]> rather than <[d.z]>. <[d.z]>
is a character class that will match a d, a "." or a z, where as
<[d..z]> is a character class that matches anything in the range of d to =
z.
0
timo
5/15/2018 2:06:01 PM
On 05/15/2018 07:06 AM, Timo Paulssen wrote:
> On 15/05/18 14:03, ToddAndMargo wrote:
>> On 05/15/2018 04:49 AM, ToddAndMargo wrote:
>>> Hi All,
>>>
>>> This should be a "no".=C2=A0 What am I doing wrong?
>>>
>>> $ perl6 -e 'my $x=3D"rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
>>> "yes"}else{say "no"}'
>>> yes
>>>
>>>
>>> Many thanks,
>>> -T
>>
>> And how do I turn this into a yes.=C2=A0 I am look for
>> any instance of d through z
>>
>> $ perl6 -e 'my $x=3D"f"; if $x~~/<[d.z]>/ {say "yes"}else{say "no"}'
>> no
>=20
> The syntax you're looking for is <[d..z]> rather than <[d.z]>. <[d.z]>
> is a character class that will match a d, a "." or a z, where as
> <[d..z]> is a character class that matches anything in the range of d t=
o z.
>=20

Thank you!

What would the syntax be for d..z, but not g or m?
0
ToddAndMargo
5/15/2018 10:10:44 PM
On 05/15/2018 07:05 AM, Timo Paulssen wrote:
> On 15/05/18 13:49, ToddAndMargo wrote:
>> Hi All,
>>
>> This should be a "no".=C2=A0 What am I doing wrong?
>>
>> $ perl6 -e 'my $x=3D"rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
>> "yes"}else{say "no"}'
>> yes
>>
>>
>> Many thanks,
>> -T
>=20
> what you've put in your regex here is a character class combined of fou=
r
> individual ones "added together";
>=20
> it matches a single letter that is either an "r", a "c", an "a", a "b",=

> or a ".". Character classes always match only a single character, if yo=
u
> want it to match more, you will have to use a quantifier, like "+", "*"=
,
> or "**". Since your regex is not anchored, it will accept any of those
> characters in any spot, so strings like "hello a" will match, too.
>=20
> It seems like what you want is actually this:
>=20
> /rc | a | b | "."/
>=20
> which matches if either "rc", "a", "b" or "." exist somewhere in the st=
ring.
>=20
> If you want to accept only if the full string is "rc", "a", "b" or ".",=

> you'll have to put anchors in the front and back, and put brackets
> around the inner part, so that the ^ and $ refer to the whole
> alternation, not just the ^ to the first variant and $ to the last vari=
ant.
>=20


Thank you!
0
ToddAndMargo
5/15/2018 10:11:25 PM
On 16/05/18 00:10, ToddAndMargo wrote:
> What would the syntax be for d..z, but not g or m?

You can subtract [gm] from [d..z] like this:

=C2=A0=C2=A0=C2=A0 say "c" ~~ /<[d..z]-[gm]>/;
=C2=A0=C2=A0=C2=A0 say "d" ~~ /<[d..z]-[gm]>/;
=C2=A0=C2=A0=C2=A0 say "f" ~~ /<[d..z]-[gm]>/;
=C2=A0=C2=A0=C2=A0 say "g" ~~ /<[d..z]-[gm]>/;
0
timo
5/16/2018 2:58:03 PM

On 05/16/2018 07:58 AM, Timo Paulssen wrote:
> On 16/05/18 00:10, ToddAndMargo wrote:
>> What would the syntax be for d..z, but not g or m?
> 
> You can subtract [gm] from [d..z] like this:
> 
>      say "c" ~~ /<[d..z]-[gm]>/;
>      say "d" ~~ /<[d..z]-[gm]>/;
>      say "f" ~~ /<[d..z]-[gm]>/;
>      say "g" ~~ /<[d..z]-[gm]>/;
> 

Something is wrong:

$ p6 'if "dgm" ~~ /<[d..z]-[gm]>/ {say "yes"}else{say "no"};'
yes

I want it to fail if it find g or m

:'(


$ alias p6
alias p6='perl6 -e'
0
ToddAndMargo
5/17/2018 1:05:05 AM
--00000000000041d3e6056c5c80ed
Content-Type: text/plain; charset="UTF-8"

You need to be more careful with regexes (any regexes). Your character
class matches if any character in the string matches, so 'd' satisfies it
and the rest of the string is ignored. If you want to ensure *no* character
matches, then say so:

pyanfar Z$ 6 'if "dgm" ~~ /^<[d..z]-[gm]>*$/ {say "y"} else {say "n"}'
n


On Wed, May 16, 2018 at 9:05 PM, Todd Chester <ToddAndMargo@zoho.com> wrote:

>
>
> On 05/16/2018 07:58 AM, Timo Paulssen wrote:
>
>> On 16/05/18 00:10, ToddAndMargo wrote:
>>
>>> What would the syntax be for d..z, but not g or m?
>>>
>>
>> You can subtract [gm] from [d..z] like this:
>>
>>      say "c" ~~ /<[d..z]-[gm]>/;
>>      say "d" ~~ /<[d..z]-[gm]>/;
>>      say "f" ~~ /<[d..z]-[gm]>/;
>>      say "g" ~~ /<[d..z]-[gm]>/;
>>
>>
> Something is wrong:
>
> $ p6 'if "dgm" ~~ /<[d..z]-[gm]>/ {say "yes"}else{say "no"};'
> yes
>
> I want it to fail if it find g or m
>
> :'(
>
>
> $ alias p6
> alias p6='perl6 -e'
>



-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b@gmail.com                                  ballbery@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

--00000000000041d3e6056c5c80ed
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">You need to be more careful with regexes (any regexes). Yo=
ur character class matches if any character in the string matches, so &#39;=
d&#39; satisfies it and the rest of the string is ignored. If you want to e=
nsure *no* character matches, then say so:<div><br></div><div><div><font fa=
ce=3D"monospace, monospace">pyanfar Z$ 6 &#39;if &quot;dgm&quot; ~~ /^&lt;[=
d..z]-[gm]&gt;*$/ {say &quot;y&quot;} else {say &quot;n&quot;}&#39;</font><=
/div><div><font face=3D"monospace, monospace">n</font></div></div><div><br>=
</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On We=
d, May 16, 2018 at 9:05 PM, Todd Chester <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt=
;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 =
..8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=3D"HOEnZb"><di=
v class=3D"h5"><br>
<br>
On 05/16/2018 07:58 AM, Timo Paulssen wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
On 16/05/18 00:10, ToddAndMargo wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">
What would the syntax be for d..z, but not g or m?<br>
</blockquote>
<br>
You can subtract [gm] from [d..z] like this:<br>
<br>
=C2=A0=C2=A0=C2=A0=C2=A0 say &quot;c&quot; ~~ /&lt;[d..z]-[gm]&gt;/;<br>
=C2=A0=C2=A0=C2=A0=C2=A0 say &quot;d&quot; ~~ /&lt;[d..z]-[gm]&gt;/;<br>
=C2=A0=C2=A0=C2=A0=C2=A0 say &quot;f&quot; ~~ /&lt;[d..z]-[gm]&gt;/;<br>
=C2=A0=C2=A0=C2=A0=C2=A0 say &quot;g&quot; ~~ /&lt;[d..z]-[gm]&gt;/;<br>
<br>
</blockquote>
<br></div></div>
Something is wrong:<br>
<br>
$ p6 &#39;if &quot;dgm&quot; ~~ /&lt;[d..z]-[gm]&gt;/ {say &quot;yes&quot;}=
else{say &quot;no&quot;};&#39;<br>
yes<br>
<br>
I want it to fail if it find g or m<br>
<br>
:&#39;(<br>
<br>
<br>
$ alias p6<br>
alias p6=3D&#39;perl6 -e&#39;<br>
</blockquote></div><br><br clear=3D"all"><div><br></div>-- <br><div class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><d=
iv>brandon s allbery kf8nh =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sine nomine associ=
ates</div><div><a href=3D"mailto:allbery.b@gmail.com" target=3D"_blank">all=
bery.b@gmail.com</a> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0<a href=
=3D"mailto:ballbery@sinenomine.net" target=3D"_blank">ballbery@sinenomine.n=
et</a></div><div>unix, openafs, kerberos, infrastructure, xmonad =C2=A0 =C2=
=A0 =C2=A0 =C2=A0<a href=3D"http://sinenomine.net" target=3D"_blank">http:/=
/sinenomine.net</a></div></div></div>
</div>

--00000000000041d3e6056c5c80ed--
0
allbery
5/17/2018 1:10:27 AM
>>> On Wed, May 16, 2018 at 9:05 PM, Todd Chester <ToddAndMargo@zoho.com 
>>> <mailto:ToddAndMargo@zoho.com>> wrote:
>>> 
>>> 
>>> 
>>>     On 05/16/2018 07:58 AM, Timo Paulssen wrote:
>>> 
>>>         On 16/05/18 00:10, ToddAndMargo wrote:
>>> 
>>>             What would the syntax be for d..z, but not g or m?
>>> 
>>> 
>>>         You can subtract [gm] from [d..z] like this:
>>> 
>>>               say "c" ~~ /<[d..z]-[gm]>/;
>>>               say "d" ~~ /<[d..z]-[gm]>/;
>>>               say "f" ~~ /<[d..z]-[gm]>/;
>>>               say "g" ~~ /<[d..z]-[gm]>/;
>>> 
>>> 

>>     Something is wrong:
>> 
>>     $ p6 'if "dgm" ~~ /<[d..z]-[gm]>/ {say "yes"}else{say "no"};'
>>     yes
>> 
>>     I want it to fail if it find g or m
>> 
>>     :'(
>> 
>> 
>>     $ alias p6
>>     alias p6='perl6 -e'




On 05/16/2018 06:10 PM, Brandon Allbery wrote:
 > You need to be more careful with regexes (any regexes). Your character
 > class matches if any character in the string matches, so 'd' satisfies
 > it and the rest of the string is ignored. If you want to ensure *no*
 > character matches, then say so:
 >
 > pyanfar Z$ 6 'if "dgm" ~~ /^<[d..z]-[gm]>*$/ {say "y"} else {say "n"}'
 > n
 >
 >


`^` for start at the beginning and `*$` for keep going all the
way to the end.

Now I understand.  Thank you!

$ p6 'if "dgm" ~~ /^<[d..z]-[gm]>*$/ {say "y"} else {say "n"}'
n

$ p6 'if "def" ~~ /^<[d..z]-[gm]>*$/ {say "y"} else {say "n"}'
y

$ p6 'if "abc" ~~ /^<[d..z]-[gm]>*$/ {say "y"} else {say "n"}'
n
0
ToddAndMargo
5/17/2018 4:52:29 AM
Now I am getting silly.

How would I exclude the phrase "gm"?

$ p6 'if "def" ~~ /^<[d..z]-["gm"]>*$/ {say "y"} else {say "n"}'
Potential difficulties:
     Quotes are not metacharacters in character classes
     at -e:1
     ------> if "def" ~~ /^<[d..z]-⏏["gm"]>*$/ {say "y"} else {say "n"}
     Repeated character (") unexpectedly found in character class
     at -e:1
     ------> if "def" ~~ /^<[d..z]-⏏["gm"]>*$/ {say "y"} else {say "n"}
0
ToddAndMargo
5/17/2018 5:08:15 AM
--------------225D6668CADC060CD95A72BA
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

character classes are fundamentally the wrong thing for "phrases", since
they describe only a character.

Your current regex (before changing [gm] to ["gm"]) was expressing "from
the start of the string, there's any amount of characters d through z
(but neither g nor m) and then the end of the string", which can be more
easily expressed as "the whole string contains only letters d through z
(but neither g nor m)".

What you apparently want is "the whole string contains only letters d
through z, but never the phrase 'gm'", which - in order to get to a
working regex - we can rephrase as "the whole string contains only
letters d through z and no occurrence of g is followed by an m". Let's
turn that into a regex:

=C2=A0=C2=A0=C2=A0 /^=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match to star=
t at the beginning of the
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # string so =
nothing can sneak in before that.
=C2=A0=C2=A0=C2=A0 [=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Everything in this g=
roup will be matched a bunch
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # of times.
=C2=A0=C2=A0=C2=A0 |=C2=A0 <[d..z]-[g]>=C2=A0 # either anything between d=
 and z, with no
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # further restrictions, exc=
ept for g.
=C2=A0=C2=A0=C2=A0 |=C2=A0 g <!before m> # If there's a g, it must not be=
 followed
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # by an m.
=C2=A0=C2=A0=C2=A0 ]*=C2=A0=C2=A0=C2=A0=C2=A0 # end of the group, allow t=
he things in the group to
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # occur any =
amount of times.
=C2=A0=C2=A0=C2=A0 $/=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match to end =
at the end of the string,
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # so nothing=
 at the end can sneak in.

Important things to note here:

  * <!before m> (spoken as "do not match before an m") will be fine with
    occurrences at the end of the string, too.
  * we don't remove the m from the character class any more, we only
    keep the g in there, because m can be in the string without
    restrictions; if there is an m after a g, our regex will already
    have failed before it even reaches the m, and all other cases are
    fine (like dm or fm or hm).
  * you are allowed to put a | not only between things, but also at the
    very front. This is allowed in the syntax so that you can line
    things up vertically like I did. Think of it as similar to allowing
    a , after the last element in a list, like with [1, 2, 3, 4, ]

> hi
> Match: =EF=BD=A2hi=EF=BD=A3
> bleh
> Match: Nil
> fog
> Match: =EF=BD=A2fog=EF=BD=A3
> dm
> Match: =EF=BD=A2dm=EF=BD=A3
> fm
> Match: =EF=BD=A2fm=EF=BD=A3
> hm
> Match: =EF=BD=A2hm=EF=BD=A3
> gm
> Match: Nil
> rofl
> Match: =EF=BD=A2rofl=EF=BD=A3
> dddddddddddg
> Match: =EF=BD=A2dddddddddddg=EF=BD=A3
> gggggggggggg
> Match: =EF=BD=A2gggggggggggg=EF=BD=A3
> mmmmmmmm
> Match: =EF=BD=A2mmmmmmmm=EF=BD=A3

Hope that helps!
=C2=A0 - Timo

--------------225D6668CADC060CD95A72BA
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf=
-8">
  </head>
  <body text=3D"#000000" bgcolor=3D"#FFFFFF">
    <p>character classes are fundamentally the wrong thing for
      "phrases", since they describe only a character.</p>
    <p>Your current regex (before changing <tt>[gm]</tt> to <tt>["gm"]</t=
t>)
      was expressing "from the start of the string, there's any amount
      of characters d through z (but neither g nor m) and then the end
      of the string", which can be more easily expressed as "the whole
      string contains only letters d through z (but neither g nor m)".</p=
>
    <p>What you apparently want is "the whole string contains only
      letters d through z, but never the phrase 'gm'", which - in order
      to get to a working regex - we can rephrase as "the whole string
      contains only letters d through z and no occurrence of g is
      followed by an m". Let's turn that into a regex:</p>
    <p><tt>=C2=A0=C2=A0=C2=A0 /^=C2=A0=C2=A0=C2=A0=C2=A0 # Require the ma=
tch to start at the beginning of
        the<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # st=
ring so nothing can sneak in before that.<br>
        =C2=A0=C2=A0=C2=A0 [=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Everything i=
n this group will be matched a bunch<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # of=
 times.<br>
        =C2=A0=C2=A0=C2=A0 |=C2=A0 &lt;[d..z]-[g]&gt;=C2=A0 # either anyt=
hing between d and z,
        with no<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # further restrict=
ions, except for g.<br>
        =C2=A0=C2=A0=C2=A0 |=C2=A0 g &lt;!before m&gt; # If there's a g, =
it must not be
        followed<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # by an m.<br>
        =C2=A0=C2=A0=C2=A0 ]*=C2=A0=C2=A0=C2=A0=C2=A0 # end of the group,=
 allow the things in the group to<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # oc=
cur any amount of times.<br>
        =C2=A0=C2=A0=C2=A0 $/=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match=
 to end at the end of the string,<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # so=
 nothing at the end can sneak in.</tt></p>
    <p>Important things to note here:</p>
    <ul>
      <li><tt>&lt;!before m&gt;</tt> (spoken as "do not match before an
        m") will be fine with occurrences at the end of the string, too.<=
/li>
      <li>we don't remove the m from the character class any more, we
        only keep the g in there, because m can be in the string without
        restrictions; if there is an m after a g, our regex will already
        have failed before it even reaches the m, and all other cases
        are fine (like dm or fm or hm).</li>
      <li>you are allowed to put a | not only between things, but also
        at the very front. This is allowed in the syntax so that you can
        line things up vertically like I did. Think of it as similar to
        allowing a , after the last element in a list, like with [1, 2,
        3, 4, ]</li>
    </ul>
    <blockquote type=3D"cite"><tt>hi</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2hi=EF=BD=A3</tt><tt><br>
      </tt><tt>bleh</tt><tt><br>
      </tt><tt>Match: Nil</tt><tt><br>
      </tt><tt>fog</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2fog=EF=BD=A3</tt><tt><br>
      </tt><tt>dm</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2dm=EF=BD=A3</tt><tt><br>
      </tt><tt>fm</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2fm=EF=BD=A3</tt><tt><br>
      </tt><tt>hm</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2hm=EF=BD=A3</tt><tt><br>
      </tt><tt>gm</tt><tt><br>
      </tt><tt>Match: Nil</tt><tt><br>
      </tt><tt>rofl</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2rofl=EF=BD=A3</tt><tt><br>
      </tt><tt>dddddddddddg</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2dddddddddddg=EF=BD=A3</tt><tt><br>
      </tt><tt>gggggggggggg</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2gggggggggggg=EF=BD=A3</tt><tt><br>
      </tt><tt>mmmmmmmm</tt><tt><br>
      </tt><tt>Match: =EF=BD=A2mmmmmmmm=EF=BD=A3</tt></blockquote>
    <br>
    Hope that helps!<br>
    =C2=A0 - Timo<br>
  </body>
</html>

--------------225D6668CADC060CD95A72BA--
0
timo
5/17/2018 10:51:37 AM
--------------DA2141E85EF7C4709CDBCFEC
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

The description perhaps doesn't point out clearly enough: the reason why
the stuff inside the [ ] will match any amount of times is only the * at
the end, the [ ] is only there because otherwise the regex would instead
match something you didn't mean at all. If you're interested, read on
for an explanation, but it might actually be more confusing than helpful:

The resulting regex means "either the beginning of the string is
followed by any letter from d to z except g, or there's a g that's
either not before an m, or it is, and followed by the end of the string".

That's because now the | would not only separate the ^ and $ anchors
into becoming alternatives, but the * would cling to the <!before m>
which is now allowed to not match at all (because it's a * and not a +).

Also, putting a quantifier (which is what * and + are called) on a
before or after assertion makes no sense and probably leads to an
infinite loop (the regex engine tries to make you proud by matching it
as often as it possibly can. which if the assertion is true, is
infinitely often. it is very diligent, but it does not really think much
about what it does).

Hope that helps
=C2=A0 - Timo


On 17/05/18 12:51, Timo Paulssen wrote:
>
> character classes are fundamentally the wrong thing for "phrases",
> since they describe only a character.
>
> Your current regex (before changing [gm] to ["gm"]) was expressing
> "from the start of the string, there's any amount of characters d
> through z (but neither g nor m) and then the end of the string", which
> can be more easily expressed as "the whole string contains only
> letters d through z (but neither g nor m)".
>
> What you apparently want is "the whole string contains only letters d
> through z, but never the phrase 'gm'", which - in order to get to a
> working regex - we can rephrase as "the whole string contains only
> letters d through z and no occurrence of g is followed by an m". Let's
> turn that into a regex:
>
> =C2=A0=C2=A0=C2=A0 /^=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match to st=
art at the beginning of the
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # string s=
o nothing can sneak in before that.
> =C2=A0=C2=A0=C2=A0 [=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Everything in this=
 group will be matched a bunch
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # of times=
..
> =C2=A0=C2=A0=C2=A0 |=C2=A0 <[d..z]-[g]>=C2=A0 # either anything between=
 d and z, with no
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # further restrictions, =
except for g.
> =C2=A0=C2=A0=C2=A0 |=C2=A0 g <!before m> # If there's a g, it must not =
be followed
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # by an m.
> =C2=A0=C2=A0=C2=A0 ]*=C2=A0=C2=A0=C2=A0=C2=A0 # end of the group, allow=
 the things in the group to
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # occur an=
y amount of times.
> =C2=A0=C2=A0=C2=A0 $/=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match to en=
d at the end of the string,
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # so nothi=
ng at the end can sneak in.
>
> Important things to note here:
>
>   * <!before m> (spoken as "do not match before an m") will be fine
>     with occurrences at the end of the string, too.
>   * we don't remove the m from the character class any more, we only
>     keep the g in there, because m can be in the string without
>     restrictions; if there is an m after a g, our regex will already
>     have failed before it even reaches the m, and all other cases are
>     fine (like dm or fm or hm).
>   * you are allowed to put a | not only between things, but also at
>     the very front. This is allowed in the syntax so that you can line
>     things up vertically like I did. Think of it as similar to
>     allowing a , after the last element in a list, like with [1, 2, 3,
>     4, ]
>
>> hi
>> Match: =EF=BD=A2hi=EF=BD=A3
>> bleh
>> Match: Nil
>> fog
>> Match: =EF=BD=A2fog=EF=BD=A3
>> dm
>> Match: =EF=BD=A2dm=EF=BD=A3
>> fm
>> Match: =EF=BD=A2fm=EF=BD=A3
>> hm
>> Match: =EF=BD=A2hm=EF=BD=A3
>> gm
>> Match: Nil
>> rofl
>> Match: =EF=BD=A2rofl=EF=BD=A3
>> dddddddddddg
>> Match: =EF=BD=A2dddddddddddg=EF=BD=A3
>> gggggggggggg
>> Match: =EF=BD=A2gggggggggggg=EF=BD=A3
>> mmmmmmmm
>> Match: =EF=BD=A2mmmmmmmm=EF=BD=A3
>
> Hope that helps!
> =C2=A0 - Timo


--------------DA2141E85EF7C4709CDBCFEC
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf=
-8">
  </head>
  <body text=3D"#000000" bgcolor=3D"#FFFFFF">
    <p>The description perhaps doesn't point out clearly enough: the
      reason why the stuff inside the [ ] will match any amount of times
      is only the * at the end, the [ ] is only there because otherwise
      the regex would instead match something you didn't mean at all. If
      you're interested, read on for an explanation, but it might
      actually be more confusing than helpful:<br>
    </p>
    <p>The resulting regex means "either the beginning of the string is
      followed by any letter from d to z except g, or there's a g that's
      either not before an m, or it is, and followed by the end of the
      string".</p>
    <p>That's because now the | would not only separate the ^ and $
      anchors into becoming alternatives, but the * would cling to the
      &lt;!before m&gt; which is now allowed to not match at all
      (because it's a * and not a +).</p>
    <p>Also, putting a quantifier (which is what * and + are called) on
      a before or after assertion makes no sense and probably leads to
      an infinite loop (the regex engine tries to make you proud by
      matching it as often as it possibly can. which if the assertion is
      true, is infinitely often. it is very diligent, but it does not
      really think much about what it does).</p>
    <p>Hope that helps<br>
      =C2=A0 - Timo<br>
    </p>
    <br>
    <div class=3D"moz-cite-prefix">On 17/05/18 12:51, Timo Paulssen wrote=
:<br>
    </div>
    <blockquote type=3D"cite"
      cite=3D"mid:866353b9-fcff-ea93-b904-78ad496eefe1@wakelift.de">
      <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Du=
tf-8">
      <p>character classes are fundamentally the wrong thing for
        "phrases", since they describe only a character.</p>
      <p>Your current regex (before changing <tt>[gm]</tt> to <tt>["gm"]<=
/tt>)
        was expressing "from the start of the string, there's any amount
        of characters d through z (but neither g nor m) and then the end
        of the string", which can be more easily expressed as "the whole
        string contains only letters d through z (but neither g nor m)".<=
/p>
      <p>What you apparently want is "the whole string contains only
        letters d through z, but never the phrase 'gm'", which - in
        order to get to a working regex - we can rephrase as "the whole
        string contains only letters d through z and no occurrence of g
        is followed by an m". Let's turn that into a regex:</p>
      <p><tt>=C2=A0=C2=A0=C2=A0 /^=C2=A0=C2=A0=C2=A0=C2=A0 # Require the =
match to start at the beginning of
          the<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # =
string so nothing can sneak in before that.<br>
          =C2=A0=C2=A0=C2=A0 [=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Everything=
 in this group will be matched a bunch<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # =
of times.<br>
          =C2=A0=C2=A0=C2=A0 |=C2=A0 &lt;[d..z]-[g]&gt;=C2=A0 # either an=
ything between d and z,
          with no<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # further restr=
ictions, except for g.<br>
          =C2=A0=C2=A0=C2=A0 |=C2=A0 g &lt;!before m&gt; # If there's a g=
, it must not be
          followed<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # by an m.<br>
          =C2=A0=C2=A0=C2=A0 ]*=C2=A0=C2=A0=C2=A0=C2=A0 # end of the grou=
p, allow the things in the group
          to<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # =
occur any amount of times.<br>
          =C2=A0=C2=A0=C2=A0 $/=C2=A0=C2=A0=C2=A0=C2=A0 # Require the mat=
ch to end at the end of the
          string,<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # =
so nothing at the end can sneak in.</tt></p>
      <p>Important things to note here:</p>
      <ul>
        <li><tt>&lt;!before m&gt;</tt> (spoken as "do not match before
          an m") will be fine with occurrences at the end of the string,
          too.</li>
        <li>we don't remove the m from the character class any more, we
          only keep the g in there, because m can be in the string
          without restrictions; if there is an m after a g, our regex
          will already have failed before it even reaches the m, and all
          other cases are fine (like dm or fm or hm).</li>
        <li>you are allowed to put a | not only between things, but also
          at the very front. This is allowed in the syntax so that you
          can line things up vertically like I did. Think of it as
          similar to allowing a , after the last element in a list, like
          with [1, 2, 3, 4, ]</li>
      </ul>
      <blockquote type=3D"cite"><tt>hi</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2hi=EF=BD=A3</tt><tt><br>
        </tt><tt>bleh</tt><tt><br>
        </tt><tt>Match: Nil</tt><tt><br>
        </tt><tt>fog</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2fog=EF=BD=A3</tt><tt><br>
        </tt><tt>dm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2dm=EF=BD=A3</tt><tt><br>
        </tt><tt>fm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2fm=EF=BD=A3</tt><tt><br>
        </tt><tt>hm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2hm=EF=BD=A3</tt><tt><br>
        </tt><tt>gm</tt><tt><br>
        </tt><tt>Match: Nil</tt><tt><br>
        </tt><tt>rofl</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2rofl=EF=BD=A3</tt><tt><br>
        </tt><tt>dddddddddddg</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2dddddddddddg=EF=BD=A3</tt><tt><br>
        </tt><tt>gggggggggggg</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2gggggggggggg=EF=BD=A3</tt><tt><br>
        </tt><tt>mmmmmmmm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2mmmmmmmm=EF=BD=A3</tt></blockquote>
      <br>
      Hope that helps!<br>
      =C2=A0 - Timo<br>
    </blockquote>
    <br>
  </body>
</html>

--------------DA2141E85EF7C4709CDBCFEC--
0
timo
5/17/2018 11:09:41 AM
--0000000000009fb1b0056c722ff2
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Nice RE tutorial :-)

/^ [ | <[d..z]-[g]> | g<!before m> ]* $/

One question I have is what is the first | for?

On Thu, 17 May 2018 at 21:10, Timo Paulssen <timo@wakelift.de> wrote:

> The description perhaps doesn't point out clearly enough: the reason why
> the stuff inside the [ ] will match any amount of times is only the * at
> the end, the [ ] is only there because otherwise the regex would instead
> match something you didn't mean at all. If you're interested, read on for
> an explanation, but it might actually be more confusing than helpful:
>
> The resulting regex means "either the beginning of the string is followed
> by any letter from d to z except g, or there's a g that's either not befo=
re
> an m, or it is, and followed by the end of the string".
>
> That's because now the | would not only separate the ^ and $ anchors into
> becoming alternatives, but the * would cling to the <!before m> which is
> now allowed to not match at all (because it's a * and not a +).
>
> Also, putting a quantifier (which is what * and + are called) on a before
> or after assertion makes no sense and probably leads to an infinite loop
> (the regex engine tries to make you proud by matching it as often as it
> possibly can. which if the assertion is true, is infinitely often. it is
> very diligent, but it does not really think much about what it does).
>
> Hope that helps
>   - Timo
>
> On 17/05/18 12:51, Timo Paulssen wrote:
>
> character classes are fundamentally the wrong thing for "phrases", since
> they describe only a character.
>
> Your current regex (before changing [gm] to ["gm"]) was expressing "from
> the start of the string, there's any amount of characters d through z (bu=
t
> neither g nor m) and then the end of the string", which can be more easil=
y
> expressed as "the whole string contains only letters d through z (but
> neither g nor m)".
>
> What you apparently want is "the whole string contains only letters d
> through z, but never the phrase 'gm'", which - in order to get to a worki=
ng
> regex - we can rephrase as "the whole string contains only letters d
> through z and no occurrence of g is followed by an m". Let's turn that in=
to
> a regex:
>
>     /^     # Require the match to start at the beginning of the
>            # string so nothing can sneak in before that.
>     [      # Everything in this group will be matched a bunch
>            # of times.
>     |  <[d..z]-[g]>  # either anything between d and z, with no
>                      # further restrictions, except for g.
>     |  g <!before m> # If there's a g, it must not be followed
>                      # by an m.
>     ]*     # end of the group, allow the things in the group to
>            # occur any amount of times.
>     $/     # Require the match to end at the end of the string,
>            # so nothing at the end can sneak in.
>
> Important things to note here:
>
>    - <!before m> (spoken as "do not match before an m") will be fine with
>    occurrences at the end of the string, too.
>    - we don't remove the m from the character class any more, we only
>    keep the g in there, because m can be in the string without restrictio=
ns;
>    if there is an m after a g, our regex will already have failed before =
it
>    even reaches the m, and all other cases are fine (like dm or fm or hm)=
..
>    - you are allowed to put a | not only between things, but also at the
>    very front. This is allowed in the syntax so that you can line things =
up
>    vertically like I did. Think of it as similar to allowing a , after th=
e
>    last element in a list, like with [1, 2, 3, 4, ]
>
> hi
> Match: =EF=BD=A2hi=EF=BD=A3
> bleh
> Match: Nil
> fog
> Match: =EF=BD=A2fog=EF=BD=A3
> dm
> Match: =EF=BD=A2dm=EF=BD=A3
> fm
> Match: =EF=BD=A2fm=EF=BD=A3
> hm
> Match: =EF=BD=A2hm=EF=BD=A3
> gm
> Match: Nil
> rofl
> Match: =EF=BD=A2rofl=EF=BD=A3
> dddddddddddg
> Match: =EF=BD=A2dddddddddddg=EF=BD=A3
> gggggggggggg
> Match: =EF=BD=A2gggggggggggg=EF=BD=A3
> mmmmmmmm
> Match: =EF=BD=A2mmmmmmmm=EF=BD=A3
>
>
> Hope that helps!
>   - Timo
>
>
>

--=20
Norman Gaywood, Computer Systems Officer
School of Science and Technology
University of New England
Armidale NSW 2351, Australia

ngaywood@une.edu.au  http://turing.une.edu.au/~ngaywood
Phone: +61 (0)2 6773 2412  Mobile: +61 (0)4 7862 0062

Please avoid sending me Word or Power Point attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

--0000000000009fb1b0056c722ff2
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Nice RE tutorial :-)</div><div><br></div><div>/^ [ | =
&lt;[d..z]-[g]&gt; | g&lt;!before m&gt; ]* $/<br></div><br><div>One questio=
n I have is what is the first | for?</div></div><br><div class=3D"gmail_quo=
te"><div dir=3D"ltr">On Thu, 17 May 2018 at 21:10, Timo Paulssen &lt;<a hre=
f=3D"mailto:timo@wakelift.de">timo@wakelift.de</a>&gt; wrote:<br></div><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #c=
cc solid;padding-left:1ex">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    <p>The description perhaps doesn&#39;t point out clearly enough: the
      reason why the stuff inside the [ ] will match any amount of times
      is only the * at the end, the [ ] is only there because otherwise
      the regex would instead match something you didn&#39;t mean at all. I=
f
      you&#39;re interested, read on for an explanation, but it might
      actually be more confusing than helpful:<br>
    </p>
    <p>The resulting regex means &quot;either the beginning of the string i=
s
      followed by any letter from d to z except g, or there&#39;s a g that&=
#39;s
      either not before an m, or it is, and followed by the end of the
      string&quot;.</p>
    <p>That&#39;s because now the | would not only separate the ^ and $
      anchors into becoming alternatives, but the * would cling to the
      &lt;!before m&gt; which is now allowed to not match at all
      (because it&#39;s a * and not a +).</p>
    <p>Also, putting a quantifier (which is what * and + are called) on
      a before or after assertion makes no sense and probably leads to
      an infinite loop (the regex engine tries to make you proud by
      matching it as often as it possibly can. which if the assertion is
      true, is infinitely often. it is very diligent, but it does not
      really think much about what it does).</p>
    <p>Hope that helps<br>
      =C2=A0 - Timo<br>
    </p>
    <br>
    <div class=3D"m_-68206126695202114moz-cite-prefix">On 17/05/18 12:51, T=
imo Paulssen wrote:<br>
    </div>
    <blockquote type=3D"cite">
     =20
      <p>character classes are fundamentally the wrong thing for
        &quot;phrases&quot;, since they describe only a character.</p>
      <p>Your current regex (before changing <tt>[gm]</tt> to <tt>[&quot;gm=
&quot;]</tt>)
        was expressing &quot;from the start of the string, there&#39;s any =
amount
        of characters d through z (but neither g nor m) and then the end
        of the string&quot;, which can be more easily expressed as &quot;th=
e whole
        string contains only letters d through z (but neither g nor m)&quot=
;.</p>
      <p>What you apparently want is &quot;the whole string contains only
        letters d through z, but never the phrase &#39;gm&#39;&quot;, which=
 - in
        order to get to a working regex - we can rephrase as &quot;the whol=
e
        string contains only letters d through z and no occurrence of g
        is followed by an m&quot;. Let&#39;s turn that into a regex:</p>
      <p><tt>=C2=A0=C2=A0=C2=A0 /^=C2=A0=C2=A0=C2=A0=C2=A0 # Require the ma=
tch to start at the beginning of
          the<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # st=
ring so nothing can sneak in before that.<br>
          =C2=A0=C2=A0=C2=A0 [=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Everything i=
n this group will be matched a bunch<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # of=
 times.<br>
          =C2=A0=C2=A0=C2=A0 |=C2=A0 &lt;[d..z]-[g]&gt;=C2=A0 # either anyt=
hing between d and z,
          with no<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # further restric=
tions, except for g.<br>
          =C2=A0=C2=A0=C2=A0 |=C2=A0 g &lt;!before m&gt; # If there&#39;s a=
 g, it must not be
          followed<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # by an m.<br>
          =C2=A0=C2=A0=C2=A0 ]*=C2=A0=C2=A0=C2=A0=C2=A0 # end of the group,=
 allow the things in the group
          to<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # oc=
cur any amount of times.<br>
          =C2=A0=C2=A0=C2=A0 $/=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match=
 to end at the end of the
          string,<br>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # so=
 nothing at the end can sneak in.</tt></p>
      <p>Important things to note here:</p>
      <ul>
        <li><tt>&lt;!before m&gt;</tt> (spoken as &quot;do not match before
          an m&quot;) will be fine with occurrences at the end of the strin=
g,
          too.</li>
        <li>we don&#39;t remove the m from the character class any more, we
          only keep the g in there, because m can be in the string
          without restrictions; if there is an m after a g, our regex
          will already have failed before it even reaches the m, and all
          other cases are fine (like dm or fm or hm).</li>
        <li>you are allowed to put a | not only between things, but also
          at the very front. This is allowed in the syntax so that you
          can line things up vertically like I did. Think of it as
          similar to allowing a , after the last element in a list, like
          with [1, 2, 3, 4, ]</li>
      </ul>
      <blockquote type=3D"cite"><tt>hi</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2hi=EF=BD=A3</tt><tt><br>
        </tt><tt>bleh</tt><tt><br>
        </tt><tt>Match: Nil</tt><tt><br>
        </tt><tt>fog</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2fog=EF=BD=A3</tt><tt><br>
        </tt><tt>dm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2dm=EF=BD=A3</tt><tt><br>
        </tt><tt>fm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2fm=EF=BD=A3</tt><tt><br>
        </tt><tt>hm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2hm=EF=BD=A3</tt><tt><br>
        </tt><tt>gm</tt><tt><br>
        </tt><tt>Match: Nil</tt><tt><br>
        </tt><tt>rofl</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2rofl=EF=BD=A3</tt><tt><br>
        </tt><tt>dddddddddddg</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2dddddddddddg=EF=BD=A3</tt><tt><br>
        </tt><tt>gggggggggggg</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2gggggggggggg=EF=BD=A3</tt><tt><br>
        </tt><tt>mmmmmmmm</tt><tt><br>
        </tt><tt>Match: =EF=BD=A2mmmmmmmm=EF=BD=A3</tt></blockquote>
      <br>
      Hope that helps!<br>
      =C2=A0 - Timo<br>
    </blockquote>
    <br>
  </div>

</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"l=
tr"><div>Norman Gaywood, Computer Systems Officer</div><div>School of Scien=
ce and Technology<br>University of New England</div><div>Armidale=C2=A0NSW =
2351, Australia<br><br><a href=3D"mailto:ngaywood@une.edu.au" target=3D"_bl=
ank">ngaywood@une.edu.au</a>=C2=A0=C2=A0<a href=3D"http://turing.une.edu.au=
/~ngaywood" target=3D"_blank">http://turing.une.edu.au/~ngaywood</a></div><=
div>Phone: +61 (0)2 6773 2412 =C2=A0Mobile: +61 (0)4 7862 0062<br><br>Pleas=
e avoid sending me Word or Power Point attachments.<br>See <a href=3D"http:=
//www.gnu.org/philosophy/no-word-attachments.html" target=3D"_blank">http:/=
/www.gnu.org/philosophy/no-word-attachments.html</a><br></div></div></div>

--0000000000009fb1b0056c722ff2--
0
ngaywood
5/18/2018 3:02:33 AM
--000000000000c4c52a056c794732
Content-Type: text/plain; charset="UTF-8"

On Thu, May 17, 2018 at 12:51 PM, Timo Paulssen <timo@wakelift.de> wrote:

> character classes are fundamentally the wrong thing for "phrases", since
> they describe only a character.
>

  You were right the first time.


> Your current regex (before changing [gm] to ["gm"]) was expressing "from
> the start of the string, there's any amount of characters d through z (but
> neither g nor m) and then the end of the string", which can be more easily
> expressed as "the whole string contains only letters d through z (but
> neither g nor m)".
>
> What you apparently want is "the whole string contains only letters d
> through z, but never the phrase 'gm'", which - in order to get to a working
> regex - we can rephrase as "the whole string contains only letters d
> through z and no occurrence of g is followed by an m". Let's turn that into
> a regex:
>
>     /^     # Require the match to start at the beginning of the
>            # string so nothing can sneak in before that.
>     [      # Everything in this group will be matched a bunch
>            # of times.
>     |  <[d..z]-[g]>  # either anything between d and z, with no
>                      # further restrictions, except for g.
>     |  g <!before m> # If there's a g, it must not be followed
>                      # by an m.
>     ]*     # end of the group, allow the things in the group to
>            # occur any amount of times.
>     $/     # Require the match to end at the end of the string,
>            # so nothing at the end can sneak in.
>
  Somewhat interesting exercise, but this kind of rephrasing doesn't scale
well for longer phrases, is hard to automate (given a phrase, which
character classes need we use?), and it's already pretty hard to read.

  If this requirement needs to be expressed in a single regex, here's what
I'd use (quickly translated from Perl5, then tested to get rid of
translation errors):

  /<!before .* gm> ^ <[d..z]>* $/

  ... or, with comments:

  /<!before .* gm> # not containing the phrase "gm" anywhere from here,
   ^ <[d..z]>* $ # match the whole string, containing only letters d
through z
  /


Eirik

--000000000000c4c52a056c794732
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Thu, May 17, 2018 at 12:51 PM, Timo Paulssen <span dir=3D"ltr">&lt;<=
a href=3D"mailto:timo@wakelift.de" target=3D"_blank">timo@wakelift.de</a>&g=
t;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF">
    <p>character classes are fundamentally the wrong thing for
      &quot;phrases&quot;, since they describe only a character.</p></div><=
/blockquote><div><br></div><div>=C2=A0 You were right the first time.<br></=
div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px =
0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div=
 bgcolor=3D"#FFFFFF">
    <p>Your current regex (before changing <tt>[gm]</tt> to <tt>[&quot;gm&q=
uot;]</tt>)
      was expressing &quot;from the start of the string, there&#39;s any am=
ount
      of characters d through z (but neither g nor m) and then the end
      of the string&quot;, which can be more easily expressed as &quot;the =
whole
      string contains only letters d through z (but neither g nor m)&quot;.=
</p>
    <p>What you apparently want is &quot;the whole string contains only
      letters d through z, but never the phrase &#39;gm&#39;&quot;, which -=
 in order
      to get to a working regex - we can rephrase as &quot;the whole string
      contains only letters d through z and no occurrence of g is
      followed by an m&quot;. Let&#39;s turn that into a regex:</p>
    <p><tt>=C2=A0=C2=A0=C2=A0 /^=C2=A0=C2=A0=C2=A0=C2=A0 # Require the matc=
h to start at the beginning of
        the<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # stri=
ng so nothing can sneak in before that.<br>
        =C2=A0=C2=A0=C2=A0 [=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Everything in =
this group will be matched a bunch<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # of t=
imes.<br>
        =C2=A0=C2=A0=C2=A0 |=C2=A0 &lt;[d..z]-[g]&gt;=C2=A0 # either anythi=
ng between d and z,
        with no<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # further restrictio=
ns, except for g.<br>
        =C2=A0=C2=A0=C2=A0 |=C2=A0 g &lt;!before m&gt; # If there&#39;s a g=
, it must not be
        followed<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # by an m.<br>
        =C2=A0=C2=A0=C2=A0 ]*=C2=A0=C2=A0=C2=A0=C2=A0 # end of the group, a=
llow the things in the group to<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # occu=
r any amount of times.<br>
        =C2=A0=C2=A0=C2=A0 $/=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match t=
o end at the end of the string,<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # so n=
othing at the end can sneak in.</tt></p></div></blockquote><div>=C2=A0 Some=
what interesting exercise, but this kind of rephrasing doesn&#39;t scale we=
ll for longer phrases, is hard to automate (given a phrase, which character=
 classes need we use?), and it&#39;s already pretty hard to read.<br></div>=
<div><br></div><div>=C2=A0 If this requirement needs to be expressed in a s=
ingle regex, here&#39;s what I&#39;d use (quickly translated from Perl5, th=
en tested to get rid of translation errors):</div><div><br></div><div>=C2=
=A0 /&lt;!before .* gm&gt; ^ &lt;[d..z]&gt;* $/<br></div><div><br></div><di=
v>=C2=A0 ... or, with comments:</div><div><br></div><div>=C2=A0 /&lt;!befor=
e .* gm&gt; # not containing the phrase &quot;gm&quot; anywhere from here,<=
/div><div>=C2=A0=C2=A0 ^ &lt;[d..z]&gt;* $ # match the whole string, contai=
ning only letters d through z<br></div><div>=C2=A0 /<br></div><div><br></di=
v><div><br></div><div>Eirik<br></div></div></div></div>

--000000000000c4c52a056c794732--
0
sidhekin
5/18/2018 11:30:33 AM
--------------23D7AC085F1AA5D9B4E328D6
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On 18/05/18 13:30, The Sidhekin wrote:
> On Thu, May 17, 2018 at 12:51 PM, Timo Paulssen <timo@wakelift.de
> <mailto:timo@wakelift.de>> wrote:
>
>     character classes are fundamentally the wrong thing for "phrases",
>     since they describe only a character.
>
>
> =C2=A0 You were right the first time.

I'm not sure what you're referring to here?

> =C2=A0[...]
>
> =C2=A0 Somewhat interesting exercise, but this kind of rephrasing doesn=
't
> scale well for longer phrases, is hard to automate (given a phrase,
> which character classes need we use?), and it's already pretty hard to
> read.

That's true, it's probably not sensible to do every regex this way. I'm
not sure how I could have done it better, though.

> =C2=A0 If this requirement needs to be expressed in a single regex, her=
e's
> what I'd use (quickly translated from Perl5, then tested to get rid of
> translation errors):
>
> =C2=A0 /<!before .* gm> ^ <[d..z]>* $/
>
> =C2=A0 ... or, with comments:
>
> =C2=A0 /<!before .* gm> # not containing the phrase "gm" anywhere from =
here,
> =C2=A0=C2=A0 ^ <[d..z]>* $ # match the whole string, containing only le=
tters d
> through z
> =C2=A0 /

That's pretty good! Putting the beginning-of-string anchor ^ anywhere
but the very start is surely an advanced move :)

=C2=A0 - Timo

--------------23D7AC085F1AA5D9B4E328D6
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dutf=
-8">
  </head>
  <body text=3D"#000000" bgcolor=3D"#FFFFFF">
    On 18/05/18 13:30, The Sidhekin wrote:<br>
    <blockquote type=3D"cite"
cite=3D"mid:CAHAeAG4WaKd7fX-ZcuTncudfZXi++EvqfA=3D9xxWgcq+yLazN8w@mail.gm=
ail.com">
      <div dir=3D"ltr">On Thu, May 17, 2018 at 12:51 PM, Timo Paulssen <s=
pan
          dir=3D"ltr">&lt;<a href=3D"mailto:timo@wakelift.de"
            target=3D"_blank" moz-do-not-send=3D"true">timo@wakelift.de</=
a>&gt;</span>
        wrote:<br>
        <div class=3D"gmail_extra">
          <div class=3D"gmail_quote">
            <blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px
              0.8ex;border-left:1px solid
              rgb(204,204,204);padding-left:1ex">
              <div bgcolor=3D"#FFFFFF">
                <p>character classes are fundamentally the wrong thing
                  for "phrases", since they describe only a character.</p=
>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>=C2=A0 You were right the first time.<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    I'm not sure what you're referring to here?<br>
    <br>
    <blockquote type=3D"cite"
cite=3D"mid:CAHAeAG4WaKd7fX-ZcuTncudfZXi++EvqfA=3D9xxWgcq+yLazN8w@mail.gm=
ail.com">
      <div dir=3D"ltr">
        <div class=3D"gmail_extra">
          <div class=3D"gmail_quote">
            <div>=C2=A0<tt>[...]<br>
                <br>
              </tt></div>
            <div>=C2=A0 Somewhat interesting exercise, but this kind of
              rephrasing doesn't scale well for longer phrases, is hard
              to automate (given a phrase, which character classes need
              we use?), and it's already pretty hard to read.<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    That's true, it's probably not sensible to do every regex this way.
    I'm not sure how I could have done it better, though.<br>
    <br>
    <blockquote type=3D"cite"
cite=3D"mid:CAHAeAG4WaKd7fX-ZcuTncudfZXi++EvqfA=3D9xxWgcq+yLazN8w@mail.gm=
ail.com">
      <div dir=3D"ltr">
        <div class=3D"gmail_extra">
          <div class=3D"gmail_quote">
            <div>=C2=A0 If this requirement needs to be expressed in a si=
ngle
              regex, here's what I'd use (quickly translated from Perl5,
              then tested to get rid of translation errors):</div>
            <div><br>
            </div>
            <div>=C2=A0 /&lt;!before .* gm&gt; ^ &lt;[d..z]&gt;* $/<br>
            </div>
            <div><br>
            </div>
            <div>=C2=A0 ... or, with comments:</div>
            <div><br>
            </div>
            <div>=C2=A0 /&lt;!before .* gm&gt; # not containing the phras=
e
              "gm" anywhere from here,</div>
            <div>=C2=A0=C2=A0 ^ &lt;[d..z]&gt;* $ # match the whole strin=
g,
              containing only letters d through z<br>
            </div>
            <div>=C2=A0 /<br>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    That's pretty good! Putting the beginning-of-string anchor <tt>^</tt>
    anywhere but the very start is surely an advanced move :)<br>
    <br>
    =C2=A0 - Timo<br>
  </body>
</html>

--------------23D7AC085F1AA5D9B4E328D6--
0
timo
5/18/2018 1:28:20 PM
--------------A524A91EDDDB0BEAF6A9EEE6
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit

On 18/05/18 05:02, Norman Gaywood wrote:
> One question I have is what is the first | for?

It was probably easy to miss, but the explanation was in the first mail
I wrote. Feel free to reply again if you have more questions about this
point, though.

>>       * you are allowed to put a | not only between things, but also
>>         at the very front. This is allowed in the syntax so that you
>>         can line things up vertically like I did. Think of it as
>>         similar to allowing a , after the last element in a list,
>>         like with [1, 2, 3, 4, ]
>>


--------------A524A91EDDDB0BEAF6A9EEE6
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: 7bit

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    On 18/05/18 05:02, Norman Gaywood wrote:<br>
    <blockquote type="cite"
cite="mid:CAHJ-_U4r9wHegz1WaVw40y_H=7GrSnzKxZ2-AXnesX64u0FPAw@mail.gmail.com">
      <div dir="ltr">One question I have is what is the first | for?</div>
    </blockquote>
    <br>
    It was probably easy to miss, but the explanation was in the first
    mail I wrote. Feel free to reply again if you have more questions
    about this point, though.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAHJ-_U4r9wHegz1WaVw40y_H=7GrSnzKxZ2-AXnesX64u0FPAw@mail.gmail.com">
      <div class="gmail_quote">
        <blockquote class="gmail_quote" style="margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div text="#000000" bgcolor="#FFFFFF">
            <blockquote type="cite">
              <ul>
                <li>you are allowed to put a | not only between things,
                  but also at the very front. This is allowed in the
                  syntax so that you can line things up vertically like
                  I did. Think of it as similar to allowing a , after
                  the last element in a list, like with [1, 2, 3, 4, ]</li>
              </ul>
            </blockquote>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
  </body>
</html>

--------------A524A91EDDDB0BEAF6A9EEE6--
0
timo
5/18/2018 1:29:51 PM
On 05/18/2018 04:30 AM, The Sidhekin wrote:
>=20
>=20
> On Thu, May 17, 2018 at 12:51 PM, Timo Paulssen <timo@wakelift.de=20
> <mailto:timo@wakelift.de>> wrote:
>=20
>     character classes are fundamentally the wrong thing for "phrases",
>     since they describe only a character.
>=20
>=20
>  =C2=A0 You were right the first time.
>=20
>     Your current regex (before changing [gm] to ["gm"]) was expressing
>     "from the start of the string, there's any amount of characters d
>     through z (but neither g nor m) and then the end of the string",
>     which can be more easily expressed as "the whole string contains
>     only letters d through z (but neither g nor m)".
>=20
>     What you apparently want is "the whole string contains only letters=

>     d through z, but never the phrase 'gm'", which - in order to get to=

>     a working regex - we can rephrase as "the whole string contains onl=
y
>     letters d through z and no occurrence of g is followed by an m".
>     Let's turn that into a regex:
>=20
>      =C2=A0=C2=A0=C2=A0 /^=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match =
to start at the beginning of the
>      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # str=
ing so nothing can sneak in before that.
>      =C2=A0=C2=A0=C2=A0 [=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # Everything in=
 this group will be matched a bunch
>      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # of =
times.
>      =C2=A0=C2=A0=C2=A0 |=C2=A0 <[d..z]-[g]>=C2=A0 # either anything be=
tween d and z, with no
>      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # further restrict=
ions, except for g.
>      =C2=A0=C2=A0=C2=A0 |=C2=A0 g <!before m> # If there's a g, it must=
 not be followed
>      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # by an m.
>      =C2=A0=C2=A0=C2=A0 ]*=C2=A0=C2=A0=C2=A0=C2=A0 # end of the group, =
allow the things in the group to
>      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # occ=
ur any amount of times.
>      =C2=A0=C2=A0=C2=A0 $/=C2=A0=C2=A0=C2=A0=C2=A0 # Require the match =
to end at the end of the string,
>      =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 # so =
nothing at the end can sneak in.
>=20
>  =C2=A0 Somewhat interesting exercise, but this kind of rephrasing does=
n't=20
> scale well for longer phrases, is hard to automate (given a phrase,=20
> which character classes need we use?), and it's already pretty hard to =
read.
>=20
>  =C2=A0 If this requirement needs to be expressed in a single regex, he=
re's=20
> what I'd use (quickly translated from Perl5, then tested to get rid of =

> translation errors):
>=20
>  =C2=A0 /<!before .* gm> ^ <[d..z]>* $/
>=20
>  =C2=A0 ... or, with comments:
>=20
>  =C2=A0 /<!before .* gm> # not containing the phrase "gm" anywhere from=
 here,
>  =C2=A0=C2=A0 ^ <[d..z]>* $ # match the whole string, containing only l=
etters d=20
> through z
>  =C2=A0 /
>=20
>=20
> Eirik


Thank you!
0
ToddAndMargo
5/18/2018 8:06:22 PM
On 05/15/2018 07:05 AM, Timo Paulssen wrote:
> On 15/05/18 13:49, ToddAndMargo wrote:
>> Hi All,
>>
>> This should be a "no".=C2=A0 What am I doing wrong?
>>
>> $ perl6 -e 'my $x=3D"rd"; if $x~~/<[rc]+[a]+[b]+[.]>/ {say
>> "yes"}else{say "no"}'
>> yes
>>
>>
>> Many thanks,
>> -T
>=20
> what you've put in your regex here is a character class combined of fou=
r
> individual ones "added together";
>=20
> it matches a single letter that is either an "r", a "c", an "a", a "b",=

> or a ".". Character classes always match only a single character, if yo=
u
> want it to match more, you will have to use a quantifier, like "+", "*"=
,
> or "**". Since your regex is not anchored, it will accept any of those
> characters in any spot, so strings like "hello a" will match, too.
>=20
> It seems like what you want is actually this:
>=20
> /rc | a | b | "."/
>=20
> which matches if either "rc", "a", "b" or "." exist somewhere in the st=
ring.
>=20
> If you want to accept only if the full string is "rc", "a", "b" or ".",=

> you'll have to put anchors in the front and back, and put brackets
> around the inner part, so that the ^ and $ refer to the whole
> alternation, not just the ^ to the first variant and $ to the last vari=
ant.
>=20


Thank you!

To match particular characters.  Any digit, any decimal point, and "rc", =

any "a", OR any "b":

     $ p6 'if "24b5" ~~ /\d |rc | a | b | "."/ {say "y"} else {say "n"}'
     y

     $ p6 'if "5" ~~ /\d |rc | a | b | "."/ {say "y"} else {say "n"}'
     y

     $ p6 'if "def" ~~ /\d |rc | a | b | "."/ {say "y"} else {say "n"}'
     n

     $p6 'if "rc" ~~ /\d | rc | a | b | "."/ {say "y"} else {say "n"}'
     y

     $ p6 'if "cr" ~~ /\d | rc | a | b | "."/ {say "y"} else {say "n"}'
     n

     $ p6 'if "rc" ~~ /\d | rc | a | b | "."/ {say "y"} else {say "n"}'
     y
0
ToddAndMargo
5/18/2018 8:22:29 PM
On 05/18/2018 01:22 PM, ToddAndMargo wrote:
> To match particular characters.

that should have been
     To match particular characters or phrases

I am using "phrase" here in the English language meaning, not
the programming meaning
0
ToddAndMargo
5/18/2018 8:32:41 PM
>> On Fri, May 18, 2018 at 1:32 PM, ToddAndMargo <ToddAndMargo@zoho.com 
>> <mailto:ToddAndMargo@zoho.com>> wrote:
>> 
>>     On 05/18/2018 01:22 PM, ToddAndMargo wrote:
>> 
>>         To match particular characters.
>> 
>> 
>>     that should have been
>>          To match particular characters or phrases
>> 
>>     I am using "phrase" here in the English language meaning, not
>>     the programming meaning
>> 
>> 

On 05/18/2018 04:14 PM, yary wrote:
> Do you want "abcdef" to say "y" or "n"?
> 
> -y
> 



Any digit, any decimal point, and "rc", any "a", OR any "b":
0
ToddAndMargo
5/18/2018 11:24:01 PM
On Fri, May 18, 2018 at 03:28:20PM +0200, Timo Paulssen wrote:
> On 18/05/18 13:30, The Sidhekin wrote:
> >
> > =A0 /<!before .* gm> ^ <[d..z]>* $/
>=20
> That's pretty good! Putting the beginning-of-string anchor ^ anywhere
> but the very start is surely an advanced move :)

FWIW, sometimes I think it's worth inverting the entire regex -- i.e., in=
stead of matching finding things that do match, exclude the things that d=
on't:

   / gm | <-[d..z]> /

This regex will match any string containing the sequence "gm" or any char=
acter that isn't in the range "d".."z", which is the inverse of what was =
required (strings containing only "d".."z" and never "gm").  Then use !~~=
 or some similar logic to get the strings wanted.

I recognize that this approach might not fit well in all cases, but it's =
another (perhaps cleaner) approach to getting what's wanted.

Pm
0
pmichaud
5/20/2018 5:40:39 PM
On 05/20/2018 10:40 AM, Patrick R. Michaud wrote:
> On Fri, May 18, 2018 at 03:28:20PM +0200, Timo Paulssen wrote:
>> On 18/05/18 13:30, The Sidhekin wrote:
>>>
>>>  =C2=A0 /<!before .* gm> ^ <[d..z]>* $/
>>
>> That's pretty good! Putting the beginning-of-string anchor ^ anywhere
>> but the very start is surely an advanced move :)
>=20
> FWIW, sometimes I think it's worth inverting the entire regex -- i.e., =
instead of matching finding things that do match, exclude the things that=
 don't:
>=20
>     / gm | <-[d..z]> /
>=20
> This regex will match any string containing the sequence "gm" or any ch=
aracter that isn't in the range "d".."z", which is the inverse of what wa=
s required (strings containing only "d".."z" and never "gm").  Then use !=
~~ or some similar logic to get the strings wanted.
>=20
> I recognize that this approach might not fit well in all cases, but it'=
s another (perhaps cleaner) approach to getting what's wanted.
>=20
> Pm
>=20



Something is wrong.  "h" is in the exclude list.

$ p6 'if "hgm" ~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
y





--=20
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
ToddAndMargo
5/20/2018 10:02:34 PM
On Sun, May 20, 2018 at 03:02:34PM -0700, ToddAndMargo wrote:
> On 05/20/2018 10:40 AM, Patrick R. Michaud wrote:
> > On Fri, May 18, 2018 at 03:28:20PM +0200, Timo Paulssen wrote:
> > > On 18/05/18 13:30, The Sidhekin wrote:
> > > >=20
> > > >  =A0 /<!before .* gm> ^ <[d..z]>* $/
> > >=20
> > > That's pretty good! Putting the beginning-of-string anchor ^ anywhe=
re
> > > but the very start is surely an advanced move :)
> >=20
> > FWIW, sometimes I think it's worth inverting the entire regex -- i.e.=
, instead of matching finding things that do match, exclude the things th=
at don't:
> >=20
> >     / gm | <-[d..z]> /
> >=20
> > This regex will match any string containing the sequence "gm" or any =
character that isn't in the range "d".."z", which is the inverse of what =
was required (strings containing only "d".."z" and never "gm").  Then use=
 !~~ or some similar logic to get the strings wanted.
> >=20
> > I recognize that this approach might not fit well in all cases, but i=
t's another (perhaps cleaner) approach to getting what's wanted.
>=20
> Something is wrong.  "h" is in the exclude list.
>=20
> $ p6 'if "hgm" ~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
> y

The string "hgm" is in the "not include" list for the other regex as well=
 (because it contains "gm"):

$ perl6 -e 'if "hgm" ~~ / <!before .* gm> ^ <[d..z]>* $/ { say "n" } else=
 { say "y" }'
y


Pm
0
pmichaud
5/20/2018 10:14:13 PM
On 05/20/2018 03:14 PM, Patrick R. Michaud wrote:
> On Sun, May 20, 2018 at 03:02:34PM -0700, ToddAndMargo wrote:
>> On 05/20/2018 10:40 AM, Patrick R. Michaud wrote:
>>> On Fri, May 18, 2018 at 03:28:20PM +0200, Timo Paulssen wrote:
>>>> On 18/05/18 13:30, The Sidhekin wrote:
>>>>>
>>>>>   =C2=A0 /<!before .* gm> ^ <[d..z]>* $/
>>>>
>>>> That's pretty good! Putting the beginning-of-string anchor ^ anywher=
e
>>>> but the very start is surely an advanced move :)
>>>
>>> FWIW, sometimes I think it's worth inverting the entire regex -- i.e.=
, instead of matching finding things that do match, exclude the things th=
at don't:
>>>
>>>      / gm | <-[d..z]> /
>>>
>>> This regex will match any string containing the sequence "gm" or any =
character that isn't in the range "d".."z", which is the inverse of what =
was required (strings containing only "d".."z" and never "gm").  Then use=
 !~~ or some similar logic to get the strings wanted.
>>>
>>> I recognize that this approach might not fit well in all cases, but i=
t's another (perhaps cleaner) approach to getting what's wanted.
>>
>> Something is wrong.  "h" is in the exclude list.
>>
>> $ p6 'if "hgm" ~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
>> y
>=20
> The string "hgm" is in the "not include" list for the other regex as we=
ll (because it contains "gm"):
>=20
> $ perl6 -e 'if "hgm" ~~ / <!before .* gm> ^ <[d..z]>* $/ { say "n" } el=
se { say "y" }'
> y
>=20
>=20
> Pm
>=20


Me still scratching me head

--=20
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Computers are like air conditioners.
They malfunction when you open windows
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
ToddAndMargo
5/20/2018 10:59:32 PM
--00000000000003a081056cab632a
Content-Type: text/plain; charset="UTF-8"

PRM's suggestion was "*inverting the entire regex -- i.e., instead of
matching finding things that do match, exclude the things that don't ...
use !~~ or some similar logic to get the strings wanted*" which IMO is an
excellent idea. Your implementation didn't take the inversion into account-
try this

p6 'if "hgm" *!~~* / gm | <-[d..z]> / {say "y"} else {say "n"}'

--00000000000003a081056cab632a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>PRM&#39;s suggestion was &quot;<i>inverting the entir=
e regex -- i.e., instead of matching finding things that do match, exclude =
the things that don&#39;t ... use !~~ or some similar logic to get the stri=
ngs wanted</i>&quot; which IMO is an excellent idea. Your implementation di=
dn&#39;t take the inversion into account- try this<br><br>p6 &#39;if &quot;=
hgm&quot; <b>!~~</b> / gm | &lt;-[d..z]&gt; / {say &quot;y&quot;} else {say=
 &quot;n&quot;}&#39;<br><br><br></div></div>

--00000000000003a081056cab632a--
0
not
5/20/2018 11:16:59 PM
On 05/20/2018 04:16 PM, yary wrote:
> PRM's suggestion was "/inverting the entire regex -- i.e., instead of 
> matching finding things that do match, exclude the things that don't ... 
> use !~~ or some similar logic to get the strings wanted/" which IMO is 
> an excellent idea. Your implementation didn't take the inversion into 
> account- try this
> 
> p6 'if "hgm" *!~~* / gm | <-[d..z]> / {say "y"} else {say "n"}'
> 
> 

p6 'if "hgm" !~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
n

$ p6 'if "cgm" !~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
n

$ p6 'if "zgm" !~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
n

$ p6 'if "z" !~~ / gm | <-[d..z]> / {say "y"} else {say "n"}'
y


Thank you!
0
ToddAndMargo
5/21/2018 12:41:46 AM
Reply: