need regex help

Hi All,

If there are any letter in the string, I want it to fail



$ p6 'my $x=3D"9.0v1"; if $x~~/<+alnum>-[<alpha>]>/ {say "Y";}'
=3D=3D=3DSORRY!=3D=3D=3D
Unrecognized regex metacharacter - (must be quoted to match literally)
at -e:1
------> my $x=3D"9.0v1"; if $x~~/<+alnum>=E2=8F=8F-[<alpha>]>/ {say "Y";}=

Unable to parse regex; couldn't find final '/'
at -e:1
------> my $x=3D"9.0v1"; if $x~~/<+alnum>-=E2=8F=8F[<alpha>]>/ {say "Y";}=




What am I doing wrong?

Many thanks,
-T
0
ToddAndMargo
8/2/2018 4:56:06 AM
perl.perl6.users 1111 articles. 0 followers. Follow

14 Replies
68 Views

Similar Articles

[PageSpeed] 38

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

\d and <digit> both match Unicode characters as well.
If that's not the intention then it's best to be explicit.

die("Horribly") unless "9.b1" ~~ / <[0-9]+> % '.' /;

Typing from my phone so unable to test the above***


On Thu, Aug 2, 2018, 12:56 AM ToddAndMargo <ToddAndMargo@zoho.com> wrote:

> Hi All,
>
> If there are any letter in the string, I want it to fail
>
>
>
> $ p6 'my $x=3D"9.0v1"; if $x~~/<+alnum>-[<alpha>]>/ {say "Y";}'
> =3D=3D=3DSORRY!=3D=3D=3D
> Unrecognized regex metacharacter - (must be quoted to match literally)
> at -e:1
> ------> my $x=3D"9.0v1"; if $x~~/<+alnum>=E2=8F=8F-[<alpha>]>/ {say "Y";}
> Unable to parse regex; couldn't find final '/'
> at -e:1
> ------> my $x=3D"9.0v1"; if $x~~/<+alnum>-=E2=8F=8F[<alpha>]>/ {say "Y";}
>
>
>
> What am I doing wrong?
>
> Many thanks,
> -T
>

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

<div dir=3D"auto"><div dir=3D"auto">\d and &lt;digit&gt; both match Unicode=
 characters as well.</div><div dir=3D"auto">If that&#39;s not the intention=
 then it&#39;s best to be explicit.</div><div dir=3D"auto"><br></div><div d=
ir=3D"auto">die(&quot;Horribly&quot;) unless &quot;9.b1&quot; ~~ / &lt;[0-9=
]+&gt; % &#39;.&#39; /;</div><div dir=3D"auto"><br></div><div dir=3D"auto">=
Typing from my phone so unable to test the above***</div><div dir=3D"auto">=
<br></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Thu, Aug 2, 20=
18, 12:56 AM ToddAndMargo &lt;<a href=3D"mailto:ToddAndMargo@zoho.com" targ=
et=3D"_blank" rel=3D"noreferrer">ToddAndMargo@zoho.com</a>&gt; wrote:<br></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">Hi All,<br>
<br>
If there are any letter in the string, I want it to fail<br>
<br>
<br>
<br>
$ p6 &#39;my $x=3D&quot;9.0v1&quot;; if $x~~/&lt;+alnum&gt;-[&lt;alpha&gt;]=
&gt;/ {say &quot;Y&quot;;}&#39;<br>
=3D=3D=3DSORRY!=3D=3D=3D<br>
Unrecognized regex metacharacter - (must be quoted to match literally)<br>
at -e:1<br>
------&gt; my $x=3D&quot;9.0v1&quot;; if $x~~/&lt;+alnum&gt;=E2=8F=8F-[&lt;=
alpha&gt;]&gt;/ {say &quot;Y&quot;;}<br>
Unable to parse regex; couldn&#39;t find final &#39;/&#39;<br>
at -e:1<br>
------&gt; my $x=3D&quot;9.0v1&quot;; if $x~~/&lt;+alnum&gt;-=E2=8F=8F[&lt;=
alpha&gt;]&gt;/ {say &quot;Y&quot;;}<br>
<br>
<br>
<br>
What am I doing wrong?<br>
<br>
Many thanks,<br>
-T<br>
</blockquote></div></div>

--000000000000720c0f05726d8dfd--
0
pprocacci
8/2/2018 6:02:02 AM
Is this what you want?

perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
=EF=BD=A212345=EF=BD=A3

perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
Nil

HTH
=C2=A0 - Timo
0
timo
8/2/2018 12:18:28 PM
--000000000000e4c38d05727681c0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

This works too:

my $x =3D "9.0v1"; die "Horribly" if $x =3D~ /[\p{L}]+/;

Art

On Thu, Aug 2, 2018 at 8:18 AM Timo Paulssen <timo@wakelift.de> wrote:

> Is this what you want?
>
> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> =EF=BD=A212345=EF=BD=A3
>
> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> Nil
>
> HTH
>   - Timo
>


--=20
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D
Arthur Ramos Jr.
207 Wisner Avenue
Middletown, NY  10940
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D
"Don't dig in against Bob Gibson, he'll knock you down. He'd knock down his
own grandmother if she dared to challenge him. Don't stare at him, don't
smile at him, don't talk to him. He doesn't like it. If you happen to hit a
home run, don't run too slow, don't run too fast. If you happen to want to
celebrate, get in the tunnel first. And if he hits you, don't charge the
mound, because he's a Gold Glove boxer." ~ Hank Aaron's advice to Dusty
Baker

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

<div dir=3D"ltr">This works too:<br><br><div>my $x =3D &quot;9.0v1&quot;; d=
ie &quot;Horribly&quot; if $x =3D~ /[\p{L}]+/;</div><div><br></div><div>Art=
</div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Thu, Aug 2, =
2018 at 8:18 AM Timo Paulssen &lt;<a href=3D"mailto:timo@wakelift.de">timo@=
wakelift.de</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Is this =
what you want?<br>
<br>
perl6 -e &#39;say &quot;12345&quot; ~~ /^&lt;+alnum -alpha&gt;+$/&#39;<br>
=EF=BD=A212345=EF=BD=A3<br>
<br>
perl6 -e &#39;say &quot;123a45&quot; ~~ /^&lt;+alnum -alpha&gt;+$/&#39;<br>
Nil<br>
<br>
HTH<br>
=C2=A0 - Timo<br>
</blockquote></div><br clear=3D"all"><div><br></div>-- <br><div dir=3D"ltr"=
 class=3D"gmail_signature" data-smartmail=3D"gmail_signature">=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D<br>Arthur Ramos Jr.<br>207 Wisner Avenue<br>Middletown, NY=
=C2=A0 10940<br>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D<br>&quot;Don&#39;t dig in aga=
inst Bob Gibson, he&#39;ll knock you down. He&#39;d knock down his own gran=
dmother if she dared to challenge him. Don&#39;t stare at him, don&#39;t sm=
ile at him, don&#39;t talk to him. He doesn&#39;t like it. If you happen to=
 hit a home run, don&#39;t run too slow, don&#39;t run too fast. If you hap=
pen to want to celebrate, get in the tunnel first. And if he hits you, don&=
#39;t charge the mound, because he&#39;s a Gold Glove boxer.&quot; ~ Hank A=
aron&#39;s advice to Dusty Baker</div>

--000000000000e4c38d05727681c0--
0
lensman
8/2/2018 4:43:02 PM
On 08/02/2018 05:18 AM, Timo Paulssen wrote:
> Is this what you want?
>=20
> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> =EF=BD=A212345=EF=BD=A3
>=20
> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> Nil
>=20
> HTH
>  =C2=A0 - Timo
>=20

A piece of art.  Thank you!
0
ToddAndMargo
8/3/2018 5:55:00 PM
On 08/02/2018 05:18 AM, Timo Paulssen wrote:
> Is this what you want?
>=20
> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> =EF=BD=A212345=EF=BD=A3
>=20
> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> Nil
>=20
> HTH
>  =C2=A0 - Timo
>=20

What does the following do?

      +alnum   (why does it need the "+"?)
      -alpha   (I presume "-" means negate?)
      +$

Many thanks,
-T
0
ToddAndMargo
8/3/2018 6:04:54 PM
If I've interpreted this
https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_ra=
nges
correctly,

^ is "start of string"
+alnum means "in the alphanumeric set"
-alpha   means "not in the purely alphabetic set"
i.e. <+alnum -alpha> means "alphanumeric but not a letter", i.e 0-9_
+ is "one or more of the preceding set"
$ is "end of string"

On 8/3/18, ToddAndMargo <ToddAndMargo@zoho.com> wrote:
> On 08/02/2018 05:18 AM, Timo Paulssen wrote:
>> Is this what you want?
>>
>> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
>> =EF=BD=A212345=EF=BD=A3
>>
>> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
>> Nil
>>
>> HTH
>>  =C2=A0 - Timo
>>
>
> What does the following do?
>
>       +alnum   (why does it need the "+"?)
>       -alpha   (I presume "-" means negate?)
>       +$
>
> Many thanks,
> -T
>
0
1parrota
8/3/2018 6:36:14 PM
--000000000000cade3305728c406b
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

That document also says that _ is considered a letter (that is, is matched
by <alpha>:
https://docs.perl6.org/language/regexes#Predefined_Character_Classes), so
that's the same thing as <digit>. I observed that earlier as well.

On Fri, Aug 3, 2018 at 2:37 PM Parrot Raiser <1parrota@gmail.com> wrote:

> If I've interpreted this
>
> https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_=
ranges
> correctly,
>
> ^ is "start of string"
> +alnum means "in the alphanumeric set"
> -alpha   means "not in the purely alphabetic set"
> i.e. <+alnum -alpha> means "alphanumeric but not a letter", i.e 0-9_
> + is "one or more of the preceding set"
> $ is "end of string"
>
> On 8/3/18, ToddAndMargo <ToddAndMargo@zoho.com> wrote:
> > On 08/02/2018 05:18 AM, Timo Paulssen wrote:
> >> Is this what you want?
> >>
> >> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> >> =EF=BD=A212345=EF=BD=A3
> >>
> >> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> >> Nil
> >>
> >> HTH
> >>    - Timo
> >>
> >
> > What does the following do?
> >
> >       +alnum   (why does it need the "+"?)
> >       -alpha   (I presume "-" means negate?)
> >       +$
> >
> > Many thanks,
> > -T
> >
>


--=20
brandon s allbery kf8nh
allbery.b@gmail.com

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

<div dir=3D"ltr">That document also says that _ is considered a letter (tha=
t is, is matched by &lt;alpha&gt;: <a href=3D"https://docs.perl6.org/langua=
ge/regexes#Predefined_Character_Classes">https://docs.perl6.org/language/re=
gexes#Predefined_Character_Classes</a>), so that&#39;s the same thing as &l=
t;digit&gt;. I observed that earlier as well.</div><br><div class=3D"gmail_=
quote"><div dir=3D"ltr">On Fri, Aug 3, 2018 at 2:37 PM Parrot Raiser &lt;<a=
 href=3D"mailto:1parrota@gmail.com">1parrota@gmail.com</a>&gt; wrote:<br></=
div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-lef=
t:1px #ccc solid;padding-left:1ex">If I&#39;ve interpreted this<br>
<a href=3D"https://docs.perl6.org/language/regexes#Enumerated_character_cla=
sses_and_ranges" rel=3D"noreferrer" target=3D"_blank">https://docs.perl6.or=
g/language/regexes#Enumerated_character_classes_and_ranges</a><br>
correctly,<br>
<br>
^ is &quot;start of string&quot;<br>
+alnum means &quot;in the alphanumeric set&quot;<br>
-alpha=C2=A0 =C2=A0means &quot;not in the purely alphabetic set&quot;<br>
i.e. &lt;+alnum -alpha&gt; means &quot;alphanumeric but not a letter&quot;,=
 i.e 0-9_<br>
+ is &quot;one or more of the preceding set&quot;<br>
$ is &quot;end of string&quot;<br>
<br>
On 8/3/18, ToddAndMargo &lt;<a href=3D"mailto:ToddAndMargo@zoho.com" target=
=3D"_blank">ToddAndMargo@zoho.com</a>&gt; wrote:<br>
&gt; On 08/02/2018 05:18 AM, Timo Paulssen wrote:<br>
&gt;&gt; Is this what you want?<br>
&gt;&gt;<br>
&gt;&gt; perl6 -e &#39;say &quot;12345&quot; ~~ /^&lt;+alnum -alpha&gt;+$/&=
#39;<br>
&gt;&gt; =EF=BD=A212345=EF=BD=A3<br>
&gt;&gt;<br>
&gt;&gt; perl6 -e &#39;say &quot;123a45&quot; ~~ /^&lt;+alnum -alpha&gt;+$/=
&#39;<br>
&gt;&gt; Nil<br>
&gt;&gt;<br>
&gt;&gt; HTH<br>
&gt;&gt;=C2=A0 =C2=A0 - Timo<br>
&gt;&gt;<br>
&gt;<br>
&gt; What does the following do?<br>
&gt;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0+alnum=C2=A0 =C2=A0(why does it need the &qu=
ot;+&quot;?)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0-alpha=C2=A0 =C2=A0(I presume &quot;-&quot; =
means negate?)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0+$<br>
&gt;<br>
&gt; Many thanks,<br>
&gt; -T<br>
&gt;<br>
</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><div dir=3D"ltr"><div>brandon s allbery kf8nh</div><div><a href=3D=
"mailto:allbery.b@gmail.com" target=3D"_blank">allbery.b@gmail.com</a></div=
></div></div></div></div>

--000000000000cade3305728c406b--
0
allbery
8/3/2018 6:39:40 PM
The + is required, perhaps because the first character after the opening
< is supposed to determine exactly what thing it is? Not sure about
that. The + and - is a bit like "start at nothing, add all alnums, then
subtract all alphas". The + after the < > is just to match it any number
of times, but at least once, and the $ at the end, together with the ^
at the start, ensures that every character in the string has to match,
not just any character.

Hope that makes sense
=C2=A0 - Timo


On 03/08/18 20:04, ToddAndMargo wrote:
> On 08/02/2018 05:18 AM, Timo Paulssen wrote:
>> Is this what you want?
>>
>> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
>> =EF=BD=A212345=EF=BD=A3
>>
>> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
>> Nil
>>
>> HTH
>> =C2=A0=C2=A0 - Timo
>>
>
> What does the following do?
>
> =C2=A0=C2=A0=C2=A0=C2=A0 +alnum=C2=A0=C2=A0 (why does it need the "+"?)
> =C2=A0=C2=A0=C2=A0=C2=A0 -alpha=C2=A0=C2=A0 (I presume "-" means negate=
?)
> =C2=A0=C2=A0=C2=A0=C2=A0 +$
>
> Many thanks,
> -T
0
timo
8/3/2018 6:48:24 PM
The + essentially indicates that this is a character-class match.  It's t=
o distinguish things from <.alpha>, <?alpha>, <!alpha>, <-alpha>, and <al=
pha> (among others).

Pm

On Fri, Aug 03, 2018 at 08:48:24PM +0200, Timo Paulssen wrote:
> The + is required, perhaps because the first character after the openin=
g
> < is supposed to determine exactly what thing it is? Not sure about
> that. The + and - is a bit like "start at nothing, add all alnums, then
> subtract all alphas". The + after the < > is just to match it any numbe=
r
> of times, but at least once, and the $ at the end, together with the ^
> at the start, ensures that every character in the string has to match,
> not just any character.
>=20
> Hope that makes sense
> =C2=A0 - Timo
>=20
>=20
> On 03/08/18 20:04, ToddAndMargo wrote:
> > On 08/02/2018 05:18 AM, Timo Paulssen wrote:
> >> Is this what you want?
> >>
> >> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> >> =EF=BD=A212345=EF=BD=A3
> >>
> >> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> >> Nil
> >>
> >> HTH
> >> =C2=A0=C2=A0 - Timo
> >>
> >
> > What does the following do?
> >
> > =C2=A0=C2=A0=C2=A0=C2=A0 +alnum=C2=A0=C2=A0 (why does it need the "+"=
?)
> > =C2=A0=C2=A0=C2=A0=C2=A0 -alpha=C2=A0=C2=A0 (I presume "-" means nega=
te?)
> > =C2=A0=C2=A0=C2=A0=C2=A0 +$
> >
> > Many thanks,
> > -T
0
pmichaud
8/3/2018 6:52:55 PM
On 08/03/2018 11:48 AM, Timo Paulssen wrote:
> The + is required, perhaps because the first character after the openin=
g
> < is supposed to determine exactly what thing it is? Not sure about
> that. The + and - is a bit like "start at nothing, add all alnums, then=

> subtract all alphas". The + after the < > is just to match it any numbe=
r
> of times, but at least once, and the $ at the end, together with the ^
> at the start, ensures that every character in the string has to match,
> not just any character.
>=20
> Hope that makes sense
>  =C2=A0 - Timo

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

Thank you!
0
ToddAndMargo
8/3/2018 9:34:30 PM
On 08/03/2018 11:36 AM, Parrot Raiser wrote:
> If I've interpreted this
> https://docs.perl6.org/language/regexes#Enumerated_character_classes_and_ranges
> correctly,
> 
> ^ is "start of string"
> +alnum means "in the alphanumeric set"
> -alpha   means "not in the purely alphabetic set"
> i.e. <+alnum -alpha> means "alphanumeric but not a letter", i.e 0-9_
> + is "one or more of the preceding set"
> $ is "end of string"

Thank you!
0
ToddAndMargo
8/3/2018 9:34:53 PM
--000000000000c939dc0572b7fe40
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Aug 2, 2018 at 8:18 AM Timo Paulssen <timo@wakelift.de> wrote:

> Is this what you want?
>
> perl6 -e 'say "12345" ~~ /^<+alnum -alpha>+$/'
> =EF=BD=A212345=EF=BD=A3
>
> perl6 -e 'say "123a45" ~~ /^<+alnum -alpha>+$/'
> Nil


On Sun, Aug 5, 2018 at 6:41 PM Arthur Ramos Jr. <lensman@winningweb.com>
wrote:

> my $x =3D "9.0v1"; die "Horribly" if $x =3D~ /[\p{L}]+/;
>
>
For that matter, you can also just use plain old unary +  (
https://docs.perl6.org/routine/+#(Operators)_prefix_+)

~$ perl6 -e 'say +"12345"'
12345
~$ perl6 -e 'say +"123a45"'
Cannot convert string to number: trailing characters after number in
'123=E2=8F=8Fa45' (indicated by =E2=8F=8F)
  in block <unit> at -e line 1

~$ perl6 -e 'say +"9.0v1"'
Cannot convert string to number: trailing characters after number in
'9.0=E2=8F=8Fv1' (indicated by =E2=8F=8F)
  in block <unit> at -e line 1

If the string is numeric, you get the number back, otherwise an exception.

Curt

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

<div dir=3D"ltr"><br><div dir=3D"ltr">On Thu, Aug 2, 2018 at 8:18 AM Timo P=
aulssen &lt;<a href=3D"mailto:timo@wakelift.de" target=3D"_blank">timo@wake=
lift.de</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"=
margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-lef=
t:1ex">Is this what you want?<br><br>perl6 -e &#39;say &quot;12345&quot; ~~=
 /^&lt;+alnum -alpha&gt;+$/&#39;<br>=EF=BD=A212345=EF=BD=A3<br><br>perl6 -e=
 &#39;say &quot;123a45&quot; ~~ /^&lt;+alnum -alpha&gt;+$/&#39;<br>Nil</blo=
ckquote><div>=C2=A0</div><div class=3D"gmail_quote"><div dir=3D"ltr">On Sun=
, Aug 5, 2018 at 6:41 PM Arthur Ramos Jr. &lt;<a href=3D"mailto:lensman@win=
ningweb.com">lensman@winningweb.com</a>&gt; wrote:<br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>my $x =3D &quot;9.=
0v1&quot;; die &quot;Horribly&quot; if $x =3D~ /[\p{L}]+/;</div><div><br></=
div></div></blockquote><div><br></div><div>For that matter, you can also ju=
st use plain old unary +=C2=A0 (<a href=3D"https://docs.perl6.org/routine/+=
#(Operators)_prefix_+">https://docs.perl6.org/routine/+#(Operators)_prefix_=
+</a>)</div><div><pre id=3D"gmail-hterm:copy-to-clipboard-source" style=3D"=
color:rgb(0,0,0)">~$ perl6 -e &#39;say +&quot;12345&quot;&#39;
12345
~$ perl6 -e &#39;say +&quot;123a45&quot;&#39;
Cannot convert string to number: trailing characters after number in &#39;1=
23=E2=8F=8Fa45&#39; (indicated by =E2=8F=8F)
  in block &lt;unit&gt; at -e line 1

~$ perl6 -e &#39;say +&quot;9.0v1&quot;&#39;
Cannot convert string to number: trailing characters after number in &#39;9=
..0=E2=8F=8Fv1&#39; (indicated by =E2=8F=8F)
  in block &lt;unit&gt; at -e line 1</pre></div><div>If the string is numer=
ic, you get the number back, otherwise an exception.</div><div><br></div><d=
iv>Curt</div><div><br></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1e=
x">
</blockquote></div></div>

--000000000000c939dc0572b7fe40--
0
curt
8/5/2018 10:50:49 PM
On 08/02/2018 09:43 AM, Arthur Ramos Jr. wrote:
> This works too:
> 
> my $x = "9.0v1"; die "Horribly" if $x =~ /[\p{L}]+/;
> 
> Art

Perl 5 by chance (=~)?  Or am I missing something?
0
ToddAndMargo
8/5/2018 11:27:29 PM
Reply: