number of letters question

Hi All,

Do we have one of those sweet functions that will
allow us to look at a string and give us back the
count of how many "letters" and/or "numbers" are
in a string?

And are decimal points considered numbers or letters?

Many thanks,
-T
0
ToddAndMargo
5/15/2018 6:31:40 AM
perl.perl6.users 954 articles. 0 followers. Follow

16 Replies
23 Views

Similar Articles

[PageSpeed] 57

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

IN Perl 6, it's a bit more complicated. Do you want to count graphemes or
codepoints?

El mar., 15 may. 2018 a las 8:32, ToddAndMargo (<ToddAndMargo@zoho.com>)
escribi=C3=B3:

> Hi All,
>
> Do we have one of those sweet functions that will
> allow us to look at a string and give us back the
> count of how many "letters" and/or "numbers" are
> in a string?
>
> And are decimal points considered numbers or letters?
>
> Many thanks,
> -T
>


--=20
JJ

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

<div dir=3D"ltr">IN Perl 6, it&#39;s a bit more complicated. Do you want to=
 count graphemes or codepoints?<br></div><br><div class=3D"gmail_quote"><di=
v dir=3D"ltr">El mar., 15 may. 2018 a las 8:32, ToddAndMargo (&lt;<a href=
=3D"mailto:ToddAndMargo@zoho.com">ToddAndMargo@zoho.com</a>&gt;) escribi=C3=
=B3:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
Do we have one of those sweet functions that will<br>
allow us to look at a string and give us back the<br>
count of how many &quot;letters&quot; and/or &quot;numbers&quot; are<br>
in a string?<br>
<br>
And are decimal points considered numbers or letters?<br>
<br>
Many thanks,<br>
-T<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g=
mail_signature" data-smartmail=3D"gmail_signature">JJ</div>

--000000000000f74168056c38f07a--
0
jjmerelo
5/15/2018 6:44:48 AM
>> El mar., 15 may. 2018 a las 8:32, ToddAndMargo (<ToddAndMargo@zoho.com=
=20
>> <mailto:ToddAndMargo@zoho.com>>) escribi=C3=B3:
>>=20
>>     Hi All,
>>=20
>>     Do we have one of those sweet functions that will
>>     allow us to look at a string and give us back the
>>     count of how many "letters" and/or "numbers" are
>>     in a string?
>>=20
>>     And are decimal points considered numbers or letters?
>>=20
>>     Many thanks,
>>     -T
>>=20

On 05/14/2018 11:44 PM, JJ Merelo wrote:
> IN Perl 6, it's a bit more complicated. Do you want to count graphemes =

> or codepoints?
>=20

I want to know the number of letters A..Z (ascii 65..90), a..z
(ascii 97..122),

and the numbers of numbers 0..9 (ascii 48..57) and decimal points
(ascii 46).

I won't have an weird characters in these stings, such as !@#$^&%(
0
ToddAndMargo
5/15/2018 7:31:10 AM
--0000000000007db622056c39ade6
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi,

El mar., 15 may. 2018 a las 9:31, ToddAndMargo (<ToddAndMargo@zoho.com>)
escribi=C3=B3:

> >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo (<ToddAndMargo@zoho.com
> >> <mailto:ToddAndMargo@zoho.com>>) escribi=C3=B3:
> >>
> >>     Hi All,
> >>
> >>     Do we have one of those sweet functions that will
> >>     allow us to look at a string and give us back the
> >>     count of how many "letters" and/or "numbers" are
> >>     in a string?
> >>
> >>     And are decimal points considered numbers or letters?
> >>
> >>     Many thanks,
> >>     -T
> >>
>
> On 05/14/2018 11:44 PM, JJ Merelo wrote:
> > IN Perl 6, it's a bit more complicated. Do you want to count graphemes
> > or codepoints?
> >
>
> I want to know the number of letters A..Z (ascii 65..90), a..z
> (ascii 97..122),
>
> and the numbers of numbers 0..9 (ascii 48..57) and decimal points
> (ascii 46).
>

Once again, that's not so simple. You don't want other kind of numbers?
Would =C3=A1 count as one a and one '?


> I won't have an weird characters in these stings, such as !@#$^&%(
>

Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?

Anyway, if that's what you want, just filter those precise graphemes and
count the number of graphemes.

Cheers

JJ
--=20
JJ

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

<div dir=3D"ltr">Hi,<br><div><br><div class=3D"gmail_quote"><div dir=3D"ltr=
">El mar., 15 may. 2018 a las 9:31, ToddAndMargo (&lt;<a href=3D"mailto:Tod=
dAndMargo@zoho.com">ToddAndMargo@zoho.com</a>&gt;) escribi=C3=B3:<br></div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">&gt;&gt; El mar., 15 may. 2018 a las 8:32, T=
oddAndMargo (&lt;<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank"=
>ToddAndMargo@zoho.com</a> <br>
&gt;&gt; &lt;mailto:<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_bla=
nk">ToddAndMargo@zoho.com</a>&gt;&gt;) escribi=C3=B3:<br>
&gt;&gt; <br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0Hi All,<br>
&gt;&gt; <br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0Do we have one of those sweet functions that wi=
ll<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0allow us to look at a string and give us back t=
he<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0count of how many &quot;letters&quot; and/or &q=
uot;numbers&quot; are<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0in a string?<br>
&gt;&gt; <br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0And are decimal points considered numbers or le=
tters?<br>
&gt;&gt; <br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0Many thanks,<br>
&gt;&gt;=C2=A0 =C2=A0 =C2=A0-T<br>
&gt;&gt; <br>
<br>
On 05/14/2018 11:44 PM, JJ Merelo wrote:<br>
&gt; IN Perl 6, it&#39;s a bit more complicated. Do you want to count graph=
emes <br>
&gt; or codepoints?<br>
&gt; <br>
<br>
I want to know the number of letters A..Z (ascii 65..90), a..z<br>
(ascii 97..122),<br>
<br>
and the numbers of numbers 0..9 (ascii 48..57) and decimal points<br>
(ascii 46).<br></blockquote><div><br></div><div>Once again, that&#39;s not =
so simple. You don&#39;t want other kind of numbers? Would =C3=A1 count as =
one a and one &#39;?</div><div> <br></div><blockquote class=3D"gmail_quote"=
 style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
I won&#39;t have an weird characters in these stings, such as !@#$^&amp;%(<=
br>
</blockquote></div><br clear=3D"all"></div><div>Whoa, whoa, whoa, you calli=
ng =C3=A1 and =C3=B1 weird? <br></div><div><br></div><div>Anyway, if that&#=
39;s what you want, just filter those precise graphemes and count the numbe=
r of graphemes. <br></div><div><br></div><div>Cheers</div><div><br></div><d=
iv>JJ<br></div><div>-- <br><div dir=3D"ltr" class=3D"gmail_signature" data-=
smartmail=3D"gmail_signature">JJ</div></div></div>

--0000000000007db622056c39ade6--
0
jjmerelo
5/15/2018 7:37:33 AM
On 05/15/2018 12:37 AM, JJ Merelo wrote:
> Hi,
>=20
> El mar., 15 may. 2018 a las 9:31, ToddAndMargo (<ToddAndMargo@zoho.com =

> <mailto:ToddAndMargo@zoho.com>>) escribi=C3=B3:
>=20
>      >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
>     (<ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>
>      >> <mailto:ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>>>)=

>     escribi=C3=B3:
>      >>
>      >>=C2=A0 =C2=A0 =C2=A0Hi All,
>      >>
>      >>=C2=A0 =C2=A0 =C2=A0Do we have one of those sweet functions that=
 will
>      >>=C2=A0 =C2=A0 =C2=A0allow us to look at a string and give us bac=
k the
>      >>=C2=A0 =C2=A0 =C2=A0count of how many "letters" and/or "numbers"=
 are
>      >>=C2=A0 =C2=A0 =C2=A0in a string?
>      >>
>      >>=C2=A0 =C2=A0 =C2=A0And are decimal points considered numbers or=
 letters?
>      >>
>      >>=C2=A0 =C2=A0 =C2=A0Many thanks,
>      >>=C2=A0 =C2=A0 =C2=A0-T
>      >>
>=20
>     On 05/14/2018 11:44 PM, JJ Merelo wrote:
>      > IN Perl 6, it's a bit more complicated. Do you want to count
>     graphemes
>      > or codepoints?
>      >
>=20
>     I want to know the number of letters A..Z (ascii 65..90), a..z
>     (ascii 97..122),
>=20
>     and the numbers of numbers 0..9 (ascii 48..57) and decimal points
>     (ascii 46).
>=20
>=20
> Once again, that's not so simple. You don't want other kind of numbers?=
=20
> Would =C3=A1 count as one a and one '?
>=20
>=20
>     I won't have an weird characters in these stings, such as !@#$^&%(
>=20
>=20
> Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?
>=20
> Anyway, if that's what you want, just filter those precise graphemes an=
d=20
> count the number of graphemes.
>=20
> Cheers
>=20
> JJ

"abcrd-12.3.4"  would be five letters, six numbers, and one
I don't care.
0
ToddAndMargo
5/15/2018 7:44:12 AM
--000000000000b7611d056c39f594
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Well,
say + "abcrd-12.3.4".comb.grep: /<alnum>/
will give you that, but
say + "abc=C3=B1=C3=A9-12.3.4".comb.grep: /<alnum>/
will yield the same result.
Roman or other kind of numerals are excluded, though...


El mar., 15 may. 2018 a las 9:44, ToddAndMargo (<ToddAndMargo@zoho.com>)
escribi=C3=B3:

> On 05/15/2018 12:37 AM, JJ Merelo wrote:
> > Hi,
> >
> > El mar., 15 may. 2018 a las 9:31, ToddAndMargo (<ToddAndMargo@zoho.com
> > <mailto:ToddAndMargo@zoho.com>>) escribi=C3=B3:
> >
> >      >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
> >     (<ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>
> >      >> <mailto:ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>>>)
> >     escribi=C3=B3:
> >      >>
> >      >>     Hi All,
> >      >>
> >      >>     Do we have one of those sweet functions that will
> >      >>     allow us to look at a string and give us back the
> >      >>     count of how many "letters" and/or "numbers" are
> >      >>     in a string?
> >      >>
> >      >>     And are decimal points considered numbers or letters?
> >      >>
> >      >>     Many thanks,
> >      >>     -T
> >      >>
> >
> >     On 05/14/2018 11:44 PM, JJ Merelo wrote:
> >      > IN Perl 6, it's a bit more complicated. Do you want to count
> >     graphemes
> >      > or codepoints?
> >      >
> >
> >     I want to know the number of letters A..Z (ascii 65..90), a..z
> >     (ascii 97..122),
> >
> >     and the numbers of numbers 0..9 (ascii 48..57) and decimal points
> >     (ascii 46).
> >
> >
> > Once again, that's not so simple. You don't want other kind of numbers?
> > Would =C3=A1 count as one a and one '?
> >
> >
> >     I won't have an weird characters in these stings, such as !@#$^&%(
> >
> >
> > Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?
> >
> > Anyway, if that's what you want, just filter those precise graphemes an=
d
> > count the number of graphemes.
> >
> > Cheers
> >
> > JJ
>
> "abcrd-12.3.4"  would be five letters, six numbers, and one
> I don't care.
>


--=20
JJ

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

<div dir=3D"ltr"><div>Well, <br></div><div>say + &quot;abcrd-12.3.4&quot;.c=
omb.grep: /&lt;alnum&gt;/</div><div>will give you that, but <br></div><div>=
say + &quot;abc=C3=B1=C3=A9-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/</div><d=
iv>will yield the same result.</div><div>Roman or other kind of numerals ar=
e excluded, though...<br></div><div><br></div></div><br><div class=3D"gmail=
_quote"><div dir=3D"ltr">El mar., 15 may. 2018 a las 9:44, ToddAndMargo (&l=
t;<a href=3D"mailto:ToddAndMargo@zoho.com">ToddAndMargo@zoho.com</a>&gt;) e=
scribi=C3=B3:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 05/15/2018 12:37 A=
M, JJ Merelo wrote:<br>
&gt; Hi,<br>
&gt; <br>
&gt; El mar., 15 may. 2018 a las 9:31, ToddAndMargo (&lt;<a href=3D"mailto:=
ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> <br>
&gt; &lt;mailto:<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">=
ToddAndMargo@zoho.com</a>&gt;&gt;) escribi=C3=B3:<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt; El mar., 15 may. 2018 a las 8:32, ToddAnd=
Margo<br>
&gt;=C2=A0 =C2=A0 =C2=A0(&lt;<a href=3D"mailto:ToddAndMargo@zoho.com" targe=
t=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto:<a href=3D"mailto:ToddAnd=
Margo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a>&gt;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt; &lt;mailto:<a href=3D"mailto:ToddAndMargo=
@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto:<a href=
=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</=
a>&gt;&gt;&gt;)<br>
&gt;=C2=A0 =C2=A0 =C2=A0escribi=C3=B3:<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Hi All,<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Do we have one of thos=
e sweet functions that will<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0allow us to look at a =
string and give us back the<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0count of how many &quo=
t;letters&quot; and/or &quot;numbers&quot; are<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0in a string?<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0And are decimal points=
 considered numbers or letters?<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Many thanks,<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0-T<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0On 05/14/2018 11:44 PM, JJ Merelo wrote:<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt; IN Perl 6, it&#39;s a bit more complicated. D=
o you want to count<br>
&gt;=C2=A0 =C2=A0 =C2=A0graphemes<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt; or codepoints?<br>
&gt;=C2=A0 =C2=A0 =C2=A0 &gt;<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0I want to know the number of letters A..Z (ascii 65=
...90), a..z<br>
&gt;=C2=A0 =C2=A0 =C2=A0(ascii 97..122),<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0and the numbers of numbers 0..9 (ascii 48..57) and =
decimal points<br>
&gt;=C2=A0 =C2=A0 =C2=A0(ascii 46).<br>
&gt; <br>
&gt; <br>
&gt; Once again, that&#39;s not so simple. You don&#39;t want other kind of=
 numbers? <br>
&gt; Would =C3=A1 count as one a and one &#39;?<br>
&gt; <br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0I won&#39;t have an weird characters in these sting=
s, such as !@#$^&amp;%(<br>
&gt; <br>
&gt; <br>
&gt; Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?<br>
&gt; <br>
&gt; Anyway, if that&#39;s what you want, just filter those precise graphem=
es and <br>
&gt; count the number of graphemes.<br>
&gt; <br>
&gt; Cheers<br>
&gt; <br>
&gt; JJ<br>
<br>
&quot;abcrd-12.3.4&quot;=C2=A0 would be five letters, six numbers, and one<=
br>
I don&#39;t care.<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g=
mail_signature" data-smartmail=3D"gmail_signature">JJ</div>

--000000000000b7611d056c39f594--
0
jjmerelo
5/15/2018 7:57:44 AM
On 05/15/2018 12:57 AM, JJ Merelo wrote:
> Well,
> say + "abcrd-12.3.4".comb.grep: /<alnum>/
> will give you that, but
> say + "abc=C3=B1=C3=A9-12.3.4".comb.grep: /<alnum>/
> will yield the same result.
> Roman or other kind of numerals are excluded, though...


$ perl6 -e 'say + "abcrd-12.3.4".comb.grep: /<alnum>/;'
9

I don't understand.

What does `/<alnum>/` do?  Is that a regex?
0
ToddAndMargo
5/15/2018 8:16:57 AM
--000000000000e8391a056c3a4f88
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

El mar., 15 may. 2018 a las 10:17, ToddAndMargo (<ToddAndMargo@zoho.com>)
escribi=C3=B3:

> On 05/15/2018 12:57 AM, JJ Merelo wrote:
> > Well,
> > say + "abcrd-12.3.4".comb.grep: /<alnum>/
> > will give you that, but
> > say + "abc=C3=B1=C3=A9-12.3.4".comb.grep: /<alnum>/
> > will yield the same result.
> > Roman or other kind of numerals are excluded, though...
>
>
> $ perl6 -e 'say + "abcrd-12.3.4".comb.grep: /<alnum>/;'
> 9
>
> I don't understand.
>
> What does `/<alnum>/` do?  Is that a regex?
>

Correct. It's the alphanumeric character class.


--=20
JJ

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

<div dir=3D"ltr"><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">El mar=
.., 15 may. 2018 a las 10:17, ToddAndMargo (&lt;<a href=3D"mailto:ToddAndMar=
go@zoho.com">ToddAndMargo@zoho.com</a>&gt;) escribi=C3=B3:<br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc =
solid;padding-left:1ex">On 05/15/2018 12:57 AM, JJ Merelo wrote:<br>
&gt; Well,<br>
&gt; say + &quot;abcrd-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/<br>
&gt; will give you that, but<br>
&gt; say + &quot;abc=C3=B1=C3=A9-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/<br=
>
&gt; will yield the same result.<br>
&gt; Roman or other kind of numerals are excluded, though...<br>
<br>
<br>
$ perl6 -e &#39;say + &quot;abcrd-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/;&=
#39;<br>
9<br>
<br>
I don&#39;t understand.<br>
<br>
What does `/&lt;alnum&gt;/` do?=C2=A0 Is that a regex?<br></blockquote><div=
><br></div><div>Correct. It&#39;s the alphanumeric character class. <br></d=
iv></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"gmail_signa=
ture" data-smartmail=3D"gmail_signature">JJ</div></div>

--000000000000e8391a056c3a4f88--
0
jjmerelo
5/15/2018 8:22:57 AM
--000000000000fe469d056c3b758f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Just a quick reminder that <alnum> matches the underscore, because <alpha>
also does.  If you want to exclude underscores, you can match against
/<+alnum-[_]>/.  That adds the alnum character class, but subtracts
underscores from it.   Decimal points are definitely not alphanumeric,
though.

On Tue, May 15, 2018 at 1:22 AM, JJ Merelo <jjmerelo@gmail.com> wrote:

>
>
> El mar., 15 may. 2018 a las 10:17, ToddAndMargo (<ToddAndMargo@zoho.com>)
> escribi=C3=B3:
>
>> On 05/15/2018 12:57 AM, JJ Merelo wrote:
>> > Well,
>> > say + "abcrd-12.3.4".comb.grep: /<alnum>/
>> > will give you that, but
>> > say + "abc=C3=B1=C3=A9-12.3.4".comb.grep: /<alnum>/
>> > will yield the same result.
>> > Roman or other kind of numerals are excluded, though...
>>
>>
>> $ perl6 -e 'say + "abcrd-12.3.4".comb.grep: /<alnum>/;'
>> 9
>>
>> I don't understand.
>>
>> What does `/<alnum>/` do?  Is that a regex?
>>
>
> Correct. It's the alphanumeric character class.
>
>
> --
> JJ
>

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

<div dir=3D"ltr">Just a quick reminder that &lt;alnum&gt; matches the under=
score, because &lt;alpha&gt; also does.=C2=A0 If you want to exclude unders=
cores, you can match against /&lt;+alnum-[_]&gt;/.=C2=A0 That adds the alnu=
m character class, but subtracts underscores from it.=C2=A0=C2=A0 Decimal p=
oints are definitely not alphanumeric, though.<br></div><div class=3D"gmail=
_extra"><br><div class=3D"gmail_quote">On Tue, May 15, 2018 at 1:22 AM, JJ =
Merelo <span dir=3D"ltr">&lt;<a href=3D"mailto:jjmerelo@gmail.com" target=
=3D"_blank">jjmerelo@gmail.com</a>&gt;</span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div dir=3D"ltr"><br><br><div class=3D"gmail_quote"><div><div=
 class=3D"h5"><div dir=3D"ltr">El mar., 15 may. 2018 a las 10:17, ToddAndMa=
rgo (&lt;<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAnd=
Margo@zoho.com</a>&gt;) escribi=C3=B3:<br></div><blockquote class=3D"gmail_=
quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1=
ex">On 05/15/2018 12:57 AM, JJ Merelo wrote:<br>
&gt; Well,<br>
&gt; say + &quot;abcrd-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/<br>
&gt; will give you that, but<br>
&gt; say + &quot;abc=C3=B1=C3=A9-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/<br=
>
&gt; will yield the same result.<br>
&gt; Roman or other kind of numerals are excluded, though...<br>
<br>
<br>
$ perl6 -e &#39;say + &quot;abcrd-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/;&=
#39;<br>
9<br>
<br>
I don&#39;t understand.<br>
<br>
What does `/&lt;alnum&gt;/` do?=C2=A0 Is that a regex?<br></blockquote><div=
><br></div></div></div><div>Correct. It&#39;s the alphanumeric character cl=
ass. <br></div></div><span class=3D"HOEnZb"><font color=3D"#888888"><br cle=
ar=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"m_3490498081522663277gmail_=
signature" data-smartmail=3D"gmail_signature">JJ</div></font></span></div>
</blockquote></div><br></div>

--000000000000fe469d056c3b758f--
0
bslaabs
5/15/2018 9:45:21 AM
On 05/15/2018 02:45 AM, Brent Laabs wrote:
> Just a quick reminder that <alnum> matches the underscore, because=20
> <alpha> also does.=C2=A0 If you want to exclude underscores, you can ma=
tch=20
> against /<+alnum-[_]>/.=C2=A0 That adds the alnum character class, but =

> subtracts underscores from it.=C2=A0=C2=A0 Decimal points are definitel=
y not=20
> alphanumeric, though.

Thank you!

Is there a list of these somewhere?
0
ToddAndMargo
5/15/2018 11:39:46 AM
On 05/15/2018 02:45 AM, Brent Laabs wrote:
>  /<+alnum-[_]>/. 

What does the `+` do?

Is there a was to write that to include decimal points
(or any other weird character)?
0
ToddAndMargo
5/15/2018 11:47:51 AM
--0000000000008d30b2056c3dbe29
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

El mar., 15 may. 2018 a las 13:48, ToddAndMargo (<ToddAndMargo@zoho.com>)
escribi=C3=B3:

> On 05/15/2018 02:45 AM, Brent Laabs wrote:
> >  /<+alnum-[_]>/.
>
> What does the `+` do?
>

+  includes a category, - eliminates one category. Check out the regexes
page https://docs.perl6.org/language/regexes

Cheers

>
> Is there a was to write that to include decimal points
> (or any other weird character)?
>


--=20
JJ

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

<div dir=3D"ltr"><br><br><div class=3D"gmail_quote"><div dir=3D"ltr">El mar=
.., 15 may. 2018 a las 13:48, ToddAndMargo (&lt;<a href=3D"mailto:ToddAndMar=
go@zoho.com">ToddAndMargo@zoho.com</a>&gt;) escribi=C3=B3:<br></div><blockq=
uote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1p=
x solid rgb(204,204,204);padding-left:1ex">On 05/15/2018 02:45 AM, Brent La=
abs wrote:<br>
&gt;=C2=A0 /&lt;+alnum-[_]&gt;/. <br>
<br>
What does the `+` do?<br></blockquote><div><br></div><div>+=C2=A0 includes =
a category, - eliminates one category. Check out the regexes page <a href=
=3D"https://docs.perl6.org/language/regexes">https://docs.perl6.org/languag=
e/regexes</a></div><div><br></div><div>Cheers<br></div><blockquote class=3D=
"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(2=
04,204,204);padding-left:1ex">
<br>
Is there a was to write that to include decimal points<br>
(or any other weird character)?<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g=
mail_signature">JJ</div></div>

--0000000000008d30b2056c3dbe29--
0
jjmerelo
5/15/2018 12:28:37 PM
--------------28976F169A67E990C873AAD6
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

I'd suggest combing for the regex instead of combing and then grepping
with the regex:

say + "abcrd-12.3.4".comb(/<alnum>/);

though from the problem question it sounds a lot more like what todd
wants is

=C2=A0=C2=A0=C2=A0 my $input =3D "abcrd-12.3.4";
=C2=A0=C2=A0=C2=A0 my $letters =3D $input.comb(/<[a..z]>/);
=C2=A0=C2=A0=C2=A0 my $numbers =3D $input.comb(/<[a..z 0..9 .]>/);
=C2=A0=C2=A0=C2=A0 say "the string $input has $letters letters and $numbe=
rs numbers and
periods.";


On 15/05/18 09:57, JJ Merelo wrote:
> Well,
> say + "abcrd-12.3.4".comb.grep: /<alnum>/
> will give you that, but
> say + "abc=C3=B1=C3=A9-12.3.4".comb.grep: /<alnum>/
> will yield the same result.
> Roman or other kind of numerals are excluded, though...
>
>
> El mar., 15 may. 2018 a las 9:44, ToddAndMargo (<ToddAndMargo@zoho.com
> <mailto:ToddAndMargo@zoho.com>>) escribi=C3=B3:
>
>     On 05/15/2018 12:37 AM, JJ Merelo wrote:
>     > Hi,
>     >
>     > El mar., 15 may. 2018 a las 9:31, ToddAndMargo
>     (<ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>
>     > <mailto:ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>>>)
>     escribi=C3=B3:
>     >
>     >=C2=A0 =C2=A0 =C2=A0 >> El mar., 15 may. 2018 a las 8:32, ToddAndM=
argo
>     >=C2=A0 =C2=A0 =C2=A0(<ToddAndMargo@zoho.com <mailto:ToddAndMargo@z=
oho.com>
>     <mailto:ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>>
>     >=C2=A0 =C2=A0 =C2=A0 >> <mailto:ToddAndMargo@zoho.com
>     <mailto:ToddAndMargo@zoho.com> <mailto:ToddAndMargo@zoho.com
>     <mailto:ToddAndMargo@zoho.com>>>>)
>     >=C2=A0 =C2=A0 =C2=A0escribi=C3=B3:
>     >=C2=A0 =C2=A0 =C2=A0 >>
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0Hi All,
>     >=C2=A0 =C2=A0 =C2=A0 >>
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0Do we have one of those=
 sweet functions that will
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0allow us to look at a s=
tring and give us back the
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0count of how many "lett=
ers" and/or "numbers" are
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0in a string?
>     >=C2=A0 =C2=A0 =C2=A0 >>
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0And are decimal points =
considered numbers or letters?
>     >=C2=A0 =C2=A0 =C2=A0 >>
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0Many thanks,
>     >=C2=A0 =C2=A0 =C2=A0 >>=C2=A0 =C2=A0 =C2=A0-T
>     >=C2=A0 =C2=A0 =C2=A0 >>
>     >
>     >=C2=A0 =C2=A0 =C2=A0On 05/14/2018 11:44 PM, JJ Merelo wrote:
>     >=C2=A0 =C2=A0 =C2=A0 > IN Perl 6, it's a bit more complicated. Do =
you want to count
>     >=C2=A0 =C2=A0 =C2=A0graphemes
>     >=C2=A0 =C2=A0 =C2=A0 > or codepoints?
>     >=C2=A0 =C2=A0 =C2=A0 >
>     >
>     >=C2=A0 =C2=A0 =C2=A0I want to know the number of letters A..Z (asc=
ii 65..90), a..z
>     >=C2=A0 =C2=A0 =C2=A0(ascii 97..122),
>     >
>     >=C2=A0 =C2=A0 =C2=A0and the numbers of numbers 0..9 (ascii 48..57)=
 and decimal
>     points
>     >=C2=A0 =C2=A0 =C2=A0(ascii 46).
>     >
>     >
>     > Once again, that's not so simple. You don't want other kind of
>     numbers?
>     > Would =C3=A1 count as one a and one '?
>     >
>     >
>     >=C2=A0 =C2=A0 =C2=A0I won't have an weird characters in these stin=
gs, such as
>     !@#$^&%(
>     >
>     >
>     > Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?
>     >
>     > Anyway, if that's what you want, just filter those precise
>     graphemes and
>     > count the number of graphemes.
>     >
>     > Cheers
>     >
>     > JJ
>
>     "abcrd-12.3.4"=C2=A0 would be five letters, six numbers, and one
>     I don't care.
>
>
>
> --=20
> JJ


--------------28976F169A67E990C873AAD6
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>I'd suggest combing for the regex instead of combing and then
      grepping with the regex:</p>
    <p>say + "abcrd-12.3.4".comb(/&lt;alnum&gt;/);</p>
    <p>though from the problem question it sounds a lot more like what
      todd wants is</p>
    <p><tt>=C2=A0=C2=A0=C2=A0 </tt><tt>my $input =3D "abcrd-12.3.4";</tt>=
<tt><br>
      </tt><tt>=C2=A0=C2=A0=C2=A0 </tt><tt>my $letters =3D $input.comb(/&=
lt;[a..z]&gt;/);<br>
        =C2=A0=C2=A0=C2=A0 my $numbers =3D $input.comb(/&lt;[a..z 0..9 .]=
&gt;/);<br>
        =C2=A0=C2=A0=C2=A0 say "the string $input has $letters letters an=
d $numbers
        numbers and periods.";<br>
      </tt></p>
    <br>
    <div class=3D"moz-cite-prefix">On 15/05/18 09:57, JJ Merelo wrote:<br=
>
    </div>
    <blockquote type=3D"cite"
cite=3D"mid:CAJoLtgfu19zd7W+O5+22yVnCMUWL+dVqaywEQ3ad6kXK455PQw@mail.gmai=
l.com">
      <div dir=3D"ltr">
        <div>Well, <br>
        </div>
        <div>say + "abcrd-12.3.4".comb.grep: /&lt;alnum&gt;/</div>
        <div>will give you that, but <br>
        </div>
        <div>say + "abc=C3=B1=C3=A9-12.3.4".comb.grep: /&lt;alnum&gt;/</d=
iv>
        <div>will yield the same result.</div>
        <div>Roman or other kind of numerals are excluded, though...<br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <div class=3D"gmail_quote">
        <div dir=3D"ltr">El mar., 15 may. 2018 a las 9:44, ToddAndMargo
          (&lt;<a href=3D"mailto:ToddAndMargo@zoho.com"
            moz-do-not-send=3D"true">ToddAndMargo@zoho.com</a>&gt;)
          escribi=C3=B3:<br>
        </div>
        <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
          .8ex;border-left:1px #ccc solid;padding-left:1ex">On
          05/15/2018 12:37 AM, JJ Merelo wrote:<br>
          &gt; Hi,<br>
          &gt; <br>
          &gt; El mar., 15 may. 2018 a las 9:31, ToddAndMargo (&lt;<a
            href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank"
            moz-do-not-send=3D"true">ToddAndMargo@zoho.com</a> <br>
          &gt; &lt;mailto:<a href=3D"mailto:ToddAndMargo@zoho.com"
            target=3D"_blank" moz-do-not-send=3D"true">ToddAndMargo@zoho.=
com</a>&gt;&gt;)
          escribi=C3=B3:<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt; El mar., 15 may. 2018 a las 8=
:32,
          ToddAndMargo<br>
          &gt;=C2=A0 =C2=A0 =C2=A0(&lt;<a href=3D"mailto:ToddAndMargo@zoh=
o.com"
            target=3D"_blank" moz-do-not-send=3D"true">ToddAndMargo@zoho.=
com</a>
          &lt;mailto:<a href=3D"mailto:ToddAndMargo@zoho.com"
            target=3D"_blank" moz-do-not-send=3D"true">ToddAndMargo@zoho.=
com</a>&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt; &lt;mailto:<a
            href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank"
            moz-do-not-send=3D"true">ToddAndMargo@zoho.com</a> &lt;mailto=
:<a
            href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank"
            moz-do-not-send=3D"true">ToddAndMargo@zoho.com</a>&gt;&gt;&gt=
;)<br>
          &gt;=C2=A0 =C2=A0 =C2=A0escribi=C3=B3:<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Hi All,<br=
>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Do we have=
 one of those sweet functions
          that will<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0allow us t=
o look at a string and give
          us back the<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0count of h=
ow many "letters" and/or
          "numbers" are<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0in a strin=
g?<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0And are de=
cimal points considered
          numbers or letters?<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Many thank=
s,<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0-T<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0On 05/14/2018 11:44 PM, JJ Merelo wrote=
:<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt; IN Perl 6, it's a bit more compli=
cated. Do you
          want to count<br>
          &gt;=C2=A0 =C2=A0 =C2=A0graphemes<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt; or codepoints?<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0I want to know the number of letters A.=
..Z (ascii
          65..90), a..z<br>
          &gt;=C2=A0 =C2=A0 =C2=A0(ascii 97..122),<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0and the numbers of numbers 0..9 (ascii =
48..57) and
          decimal points<br>
          &gt;=C2=A0 =C2=A0 =C2=A0(ascii 46).<br>
          &gt; <br>
          &gt; <br>
          &gt; Once again, that's not so simple. You don't want other
          kind of numbers? <br>
          &gt; Would =C3=A1 count as one a and one '?<br>
          &gt; <br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0I won't have an weird characters in the=
se stings,
          such as !@#$^&amp;%(<br>
          &gt; <br>
          &gt; <br>
          &gt; Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?<br>
          &gt; <br>
          &gt; Anyway, if that's what you want, just filter those
          precise graphemes and <br>
          &gt; count the number of graphemes.<br>
          &gt; <br>
          &gt; Cheers<br>
          &gt; <br>
          &gt; JJ<br>
          <br>
          "abcrd-12.3.4"=C2=A0 would be five letters, six numbers, and on=
e<br>
          I don't care.<br>
        </blockquote>
      </div>
      <br clear=3D"all">
      <br>
      -- <br>
      <div dir=3D"ltr" class=3D"gmail_signature"
        data-smartmail=3D"gmail_signature">JJ</div>
    </blockquote>
    <br>
  </body>
</html>

--------------28976F169A67E990C873AAD6--
0
timo
5/15/2018 2:10:05 PM
On Tue, May 15, 2018 at 12:44:12AM -0700, ToddAndMargo wrote:
: "abcrd-12.3.4"  would be five letters, six numbers, and one
: I don't care.

Here's another approach:

    $ p6 '"abcrd-12.3.4".comb.classify(*.uniprop).say'
    {Ll => [a b c r d], Nd => [1 2 3 4], Pd => [-], Po => [. .]}

    $ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag.say'
    Bag(Ll(5), Nd(4), Pd, Po(2))

    $ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag<Ll Nd Po>.say'
    (5 4 2)

Whenever you want a histogram, consider using classify or bags.

It's a bit odd to count dots as numbers, so Unicode counts it as
Punctionation Other, but if you assume there or no other characters in
the Po category than dot, you can just add the Po to the Nd total.

Otherwise you might need to use classify and grep out the dots from the
Po category to count them.  (You can't use a bag for that approach since
it throws away the information on which Po character it saw.)

Alternately, you could just make a bag of the raw characters and then
use slicing to define each the category and add up the values for each
character

    $ p6 '"abcrd-12.3.4".comb.Bag{"a"..."z"}.sum.say'
    5
    $ p6 '"abcrd-12.3.4".comb.Bag{"0"..."9", "."}.sum.say'
    6

That's more ASCII friendly, but ASCII is not always your friend.  :-)

Larry
0
larry
5/15/2018 5:05:26 PM
--000000000000af27d0056c42b81a
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

> though from the problem question it sounds a lot more like what todd
wants is

    my $input =3D "abcrd-12.3.4";
    my $letters =3D $input.comb(/<[a..z]>/);
    my $numbers =3D $input.comb(/<[a..z 0..9 .]>/);
    say "the string $input has $letters letters and $numbers numbers and
periods.";
Just a note, I had to add a "+" to those assignments

    my $letters =3D +$input.comb(/<[a..z]>/);
    my $numbers =3D +$input.comb(/<[a..z 0..9 .]>/);

or otherwise I got a string of the "combed" chars:
the string abcrd-12.3.4 has a b c r d letters and a b c r d 1 2 . 3 . 4
numbers and periods.

On Tue, May 15, 2018 at 9:10 AM, Timo Paulssen <timo@wakelift.de> wrote:

> I'd suggest combing for the regex instead of combing and then grepping
> with the regex:
>
> say + "abcrd-12.3.4".comb(/<alnum>/);
>
> though from the problem question it sounds a lot more like what todd want=
s
> is
>
>     my $input =3D "abcrd-12.3.4";
>     my $letters =3D $input.comb(/<[a..z]>/);
>     my $numbers =3D $input.comb(/<[a..z 0..9 .]>/);
>     say "the string $input has $letters letters and $numbers numbers and
> periods.";
>
> On 15/05/18 09:57, JJ Merelo wrote:
>
> Well,
> say + "abcrd-12.3.4".comb.grep: /<alnum>/
> will give you that, but
> say + "abc=C3=B1=C3=A9-12.3.4".comb.grep: /<alnum>/
> will yield the same result.
> Roman or other kind of numerals are excluded, though...
>
>
> El mar., 15 may. 2018 a las 9:44, ToddAndMargo (<ToddAndMargo@zoho.com>)
> escribi=C3=B3:
>
>> On 05/15/2018 12:37 AM, JJ Merelo wrote:
>> > Hi,
>> >
>> > El mar., 15 may. 2018 a las 9:31, ToddAndMargo (<ToddAndMargo@zoho.com
>> > <mailto:ToddAndMargo@zoho.com>>) escribi=C3=B3:
>> >
>> >      >> El mar., 15 may. 2018 a las 8:32, ToddAndMargo
>> >     (<ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>
>> >      >> <mailto:ToddAndMargo@zoho.com <mailto:ToddAndMargo@zoho.com>>>=
)
>> >     escribi=C3=B3:
>> >      >>
>> >      >>     Hi All,
>> >      >>
>> >      >>     Do we have one of those sweet functions that will
>> >      >>     allow us to look at a string and give us back the
>> >      >>     count of how many "letters" and/or "numbers" are
>> >      >>     in a string?
>> >      >>
>> >      >>     And are decimal points considered numbers or letters?
>> >      >>
>> >      >>     Many thanks,
>> >      >>     -T
>> >      >>
>> >
>> >     On 05/14/2018 11:44 PM, JJ Merelo wrote:
>> >      > IN Perl 6, it's a bit more complicated. Do you want to count
>> >     graphemes
>> >      > or codepoints?
>> >      >
>> >
>> >     I want to know the number of letters A..Z (ascii 65..90), a..z
>> >     (ascii 97..122),
>> >
>> >     and the numbers of numbers 0..9 (ascii 48..57) and decimal points
>> >     (ascii 46).
>> >
>> >
>> > Once again, that's not so simple. You don't want other kind of numbers=
?
>> > Would =C3=A1 count as one a and one '?
>> >
>> >
>> >     I won't have an weird characters in these stings, such as !@#$^&%(
>> >
>> >
>> > Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?
>> >
>> > Anyway, if that's what you want, just filter those precise graphemes
>> and
>> > count the number of graphemes.
>> >
>> > Cheers
>> >
>> > JJ
>>
>> "abcrd-12.3.4"  would be five letters, six numbers, and one
>> I don't care.
>>
>
>
> --
> JJ
>
>
>


--=20

a

Andy Bach,
afbach@gmail.com
608 658-1890 cell
608 261-5738 wk

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

<div dir=3D"ltr">&gt; though from the problem question it sounds a lot more=
 like what
      todd wants is
    <p><tt>=C2=A0=C2=A0=C2=A0 </tt><tt>my $input =3D &quot;abcrd-12.3.4&quo=
t;;</tt><tt><br>
      </tt><tt>=C2=A0=C2=A0=C2=A0 </tt><tt>my $letters =3D $input.comb(/&lt=
;[a..z]&gt;/);<br>
        =C2=A0=C2=A0=C2=A0 my $numbers =3D $input.comb(/&lt;[a..z 0..9 .]&g=
t;/);<br>
        =C2=A0=C2=A0=C2=A0 say &quot;the string $input has $letters letters=
 and $numbers
        numbers and periods.&quot;;<br>
      </tt></p><div class=3D"gmail-yj6qo gmail-ajU"><div id=3D"gmail-:2dk" =
class=3D"gmail-ajR" tabindex=3D"0"><img class=3D"gmail-ajT" src=3D"https://=
ssl.gstatic.com/ui/v1/icons/mail/images/cleardot.gif">Just a note, I had to=
 add a &quot;+&quot; to those assignments<br></div></div><tt><br>
      </tt><tt>=C2=A0=C2=A0=C2=A0 </tt><tt>my $letters =3D +$input.comb(/&l=
t;[a..z]&gt;/);<br></tt><div><tt>
        =C2=A0=C2=A0=C2=A0 my $numbers =3D +$input.comb(/&lt;[a..z 0..9 .]&=
gt;/);<br></tt></div><div></div><div><tt></tt></div><div><br></div><div>or =
otherwise I got a string of the &quot;combed&quot; chars:</div><div>the str=
ing abcrd-12.3.4 has a b c r d letters and a b c r d 1 2 . 3 . 4 numbers an=
d periods.<br></div></div><div class=3D"gmail_extra"><br><div class=3D"gmai=
l_quote">On Tue, May 15, 2018 at 9:10 AM, Timo Paulssen <span dir=3D"ltr">&=
lt;<a href=3D"mailto:timo@wakelift.de" target=3D"_blank">timo@wakelift.de</=
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">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    <p>I&#39;d suggest combing for the regex instead of combing and then
      grepping with the regex:</p>
    <p>say + &quot;abcrd-12.3.4&quot;.comb(/&lt;alnum&gt;/)<wbr>;</p>
    <p>though from the problem question it sounds a lot more like what
      todd wants is</p>
    <p><tt>=C2=A0=C2=A0=C2=A0 </tt><tt>my $input =3D &quot;abcrd-12.3.4&quo=
t;;</tt><tt><br>
      </tt><tt>=C2=A0=C2=A0=C2=A0 </tt><tt>my $letters =3D $input.comb(/&lt=
;[a..z]&gt;/);<br>
        =C2=A0=C2=A0=C2=A0 my $numbers =3D $input.comb(/&lt;[a..z 0..9 .]&g=
t;/);<br>
        =C2=A0=C2=A0=C2=A0 say &quot;the string $input has $letters letters=
 and $numbers
        numbers and periods.&quot;;<br>
      </tt></p><div><div class=3D"h5">
    <br>
    <div class=3D"m_1812742834469004469moz-cite-prefix">On 15/05/18 09:57, =
JJ Merelo wrote:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div>Well, <br>
        </div>
        <div>say + &quot;abcrd-12.3.4&quot;.comb.grep: /&lt;alnum&gt;/</div=
>
        <div>will give you that, but <br>
        </div>
        <div>say + &quot;abc=C3=B1=C3=A9-12.3.4&quot;.comb.grep: /&lt;alnum=
&gt;/</div>
        <div>will yield the same result.</div>
        <div>Roman or other kind of numerals are excluded, though...<br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <div class=3D"gmail_quote">
        <div dir=3D"ltr">El mar., 15 may. 2018 a las 9:44, ToddAndMargo
          (&lt;<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">T=
oddAndMargo@zoho.com</a>&gt;)
          escribi=C3=B3:<br>
        </div>
        <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border=
-left:1px #ccc solid;padding-left:1ex">On
          05/15/2018 12:37 AM, JJ Merelo wrote:<br>
          &gt; Hi,<br>
          &gt; <br>
          &gt; El mar., 15 may. 2018 a las 9:31, ToddAndMargo (&lt;<a href=
=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</=
a> <br>
          &gt; &lt;mailto:<a href=3D"mailto:ToddAndMargo@zoho.com" target=
=3D"_blank">ToddAndMargo@zoho.com</a>&gt;<wbr>&gt;)
          escribi=C3=B3:<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt; El mar., 15 may. 2018 a las 8:3=
2,
          ToddAndMargo<br>
          &gt;=C2=A0 =C2=A0 =C2=A0(&lt;<a href=3D"mailto:ToddAndMargo@zoho.=
com" target=3D"_blank">ToddAndMargo@zoho.com</a>
          &lt;mailto:<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_bl=
ank">ToddAndMargo@zoho.com</a>&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt; &lt;mailto:<a href=3D"mailto:To=
ddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zoho.com</a> &lt;mailto=
:<a href=3D"mailto:ToddAndMargo@zoho.com" target=3D"_blank">ToddAndMargo@zo=
ho.com</a>&gt;<wbr>&gt;&gt;)<br>
          &gt;=C2=A0 =C2=A0 =C2=A0escribi=C3=B3:<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Hi All,<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Do we have o=
ne of those sweet functions
          that will<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0allow us to =
look at a string and give
          us back the<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0count of how=
 many &quot;letters&quot; and/or
          &quot;numbers&quot; are<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0in a string?=
<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0And are deci=
mal points considered
          numbers or letters?<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0Many thanks,=
<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;=C2=A0 =C2=A0 =C2=A0-T<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;&gt;<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0On 05/14/2018 11:44 PM, JJ Merelo wrote:<=
br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt; IN Perl 6, it&#39;s a bit more comp=
licated. Do you
          want to count<br>
          &gt;=C2=A0 =C2=A0 =C2=A0graphemes<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt; or codepoints?<br>
          &gt;=C2=A0 =C2=A0 =C2=A0 &gt;<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0I want to know the number of letters A..Z=
 (ascii
          65..90), a..z<br>
          &gt;=C2=A0 =C2=A0 =C2=A0(ascii 97..122),<br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0and the numbers of numbers 0..9 (ascii 48=
...57) and
          decimal points<br>
          &gt;=C2=A0 =C2=A0 =C2=A0(ascii 46).<br>
          &gt; <br>
          &gt; <br>
          &gt; Once again, that&#39;s not so simple. You don&#39;t want oth=
er
          kind of numbers? <br>
          &gt; Would =C3=A1 count as one a and one &#39;?<br>
          &gt; <br>
          &gt; <br>
          &gt;=C2=A0 =C2=A0 =C2=A0I won&#39;t have an weird characters in t=
hese stings,
          such as !@#$^&amp;%(<br>
          &gt; <br>
          &gt; <br>
          &gt; Whoa, whoa, whoa, you calling =C3=A1 and =C3=B1 weird?<br>
          &gt; <br>
          &gt; Anyway, if that&#39;s what you want, just filter those
          precise graphemes and <br>
          &gt; count the number of graphemes.<br>
          &gt; <br>
          &gt; Cheers<br>
          &gt; <br>
          &gt; JJ<br>
          <br>
          &quot;abcrd-12.3.4&quot;=C2=A0 would be five letters, six numbers=
, and one<br>
          I don&#39;t care.<br>
        </blockquote>
      </div>
      <br clear=3D"all">
      <br>
      -- <br>
      <div dir=3D"ltr" class=3D"m_1812742834469004469gmail_signature" data-=
smartmail=3D"gmail_signature">JJ</div>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature" data-smartmail=3D"gmail_signature"><br>a<br><br>Andy Bach,<br><a hr=
ef=3D"mailto:afbach@gmail.com" target=3D"_blank">afbach@gmail.com</a><br>60=
8 658-1890 cell<br>608 261-5738 wk</div>
</div>

--000000000000af27d0056c42b81a--
0
afbach
5/15/2018 6:25:04 PM
On 05/15/2018 10:05 AM, Larry Wall wrote:
> On Tue, May 15, 2018 at 12:44:12AM -0700, ToddAndMargo wrote:
> : "abcrd-12.3.4"  would be five letters, six numbers, and one
> : I don't care.
> 
> Here's another approach:
> 
>      $ p6 '"abcrd-12.3.4".comb.classify(*.uniprop).say'
>      {Ll => [a b c r d], Nd => [1 2 3 4], Pd => [-], Po => [. .]}
> 
>      $ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag.say'
>      Bag(Ll(5), Nd(4), Pd, Po(2))
> 
>      $ p6 '"abcrd-12.3.4".comb.map(*.uniprop).Bag<Ll Nd Po>.say'
>      (5 4 2)
> 
> Whenever you want a histogram, consider using classify or bags.
> 
> It's a bit odd to count dots as numbers, so Unicode counts it as
> Punctionation Other, but if you assume there or no other characters in
> the Po category than dot, you can just add the Po to the Nd total.
> 
> Otherwise you might need to use classify and grep out the dots from the
> Po category to count them.  (You can't use a bag for that approach since
> it throws away the information on which Po character it saw.)
> 
> Alternately, you could just make a bag of the raw characters and then
> use slicing to define each the category and add up the values for each
> character
> 
>      $ p6 '"abcrd-12.3.4".comb.Bag{"a"..."z"}.sum.say'
>      5
>      $ p6 '"abcrd-12.3.4".comb.Bag{"0"..."9", "."}.sum.say'
>      6
> 
> That's more ASCII friendly, but ASCII is not always your friend.  :-)
> 
> Larry
> 

Hi Larry,

Thank you!

I am going to have to read it over several time!  But
I will get there!

-T
0
ToddAndMargo
5/15/2018 10:14:51 PM
That is absolutely correct, thanks!
0
timo
5/16/2018 2:55:24 PM
Reply: