...Well, there were no 'only latin number symbols are allowed in user
input' clauses, so \d seems to be more suitable than mere [0-9]. And
for most of my cases \d was sufficient yet shorter than [0-9] - and more
readable, somewhat ironically...

There goes 'why' part. ) And we both, I suppose, may only guess whether or
not /d may be unicode-widened in this case.

But the point is that you're right, and I'm wrong, because the context of
\d (as \w and \s) may be affected by something mildly unrelated to the
containing regex. And that, in my opinion, makes it definitely the bad
thing to teach the beginners. )

So yes, it's safer to go with [0-9]. TIMTOWTDI, of course: using /a
modifier alongside \d-\w-\s. It's even better (as it 'fixes' the context
even for compound regexes, as I understand), but is available only since
5.14.

-- iD

2012/2/22 Dr.Ruud <rvtol+use...@isolution.nl>

> On 2012-02-22 21:48, Igor Dovgiy wrote:
>
>  Anyway, if you're looking for integers only, as assumed previously, the
>> corresponding check should be made of this:
>> *match the beginning of the line marker, then, optionally, a minus sign,
>> then any number of digits, then the end of the line marker*, or just
>> /^-?\d+$/
>>
>
> Igor, you switched from [0-9] to \d.
> Spoiler: the \d matches 250+ code points.
> Why did you switch?
>
> --
> Ruud
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to