develooper Front page | perl.perl5.porters | Postings from October 2017

Re: [perl #132278] perlbug AutoReply: looks_like_number returns trueon "- "

Thread Next
From:
Stephane CHAZELAS
Date:
October 13, 2017 06:11
Subject:
Re: [perl #132278] perlbug AutoReply: looks_like_number returns trueon "- "
Message ID:
20171013054220.GA7775@chaz.gmail.com
2017-10-12 14:38:27 -0700, perlbug-followup@perl.org:
> It seems like the intention is for it to match on
> 
> ^\s*((?i:[-+]\d*\.?\d+(e[-+]?\d+)?|inf(inity)?|nan)|0 but true)\s*$
> 
> though it's hard to tell for sure from the source.

Sorry, it's probably more like:

^((?i:\s*[-+]?(\d*[$r.]?\d+(e[-+]?\d+)?|inf(inity)?|nan)\s*)|0 but true)$

as nan/inf can have a sign, but "0 but true" has to be exactly
like that (no sign or surrounding whitespace). (there were a few
more basic errors in my previous approximation, sorry it was
late).

$r is the locale's radix character under "use locale"¹ ("." is
still supported even if the locale uses another one). While the
\s seems to be only the ASCII white space (not U+2006 for
instance regardless of the locale).

¹ while it works on GNU/Linux, someone reports the radix
character is not honoured on OpenBSD:
https://unix.stackexchange.com/questions/397784/only-allow-floating-points-regex/397795?noredirect=1#comment710239_397795

Cheers,
Stephane

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About