in reply to Should be a simple spaces/digits regex....but I'm turning grey!

# n-1 spaces or digits: vv vvvvv: last digit (?:(?=\s[\s0-9]|[0-9]{2})[\s0-9]){15}[0-9] # (^^^^^^^^^^^^^^^^) ^^^^^^^: leading chars

and only allow \s\s, \s\d, or \d\d at each point along the way.

Note that I always use [0-9] and never \d as, these days, \d includes tons of characters besides '0'..'9'.

- tye        

Replies are listed 'Best First'.
Re^2: Should be a simple spaces/digits regex....but I'm turning grey! (?=)
by Bethany (Scribe) on Aug 05, 2014 at 02:16 UTC
    Note that I always use 0-9 and never \d as, these days, \d includes tons of characters besides '0'..'9'.
    That's news to me. Something to read up on, update rusty skills.
Re^2: Should be a simple spaces/digits regex....but I'm turning grey! (?=)
by Anonymous Monk on Aug 05, 2014 at 02:25 UTC

      Yeah, if you've got a version of Perl that supports such. Way too many versions of Perl after \d began including Klingon* digits yet before /a was implemented.

      Plus, /a messes with more than just \d. I have yet to run into a single project I was involved in where a string of Klingon* digits would be correctly parsed as a numeric value. But I've touched plenty of projects where \w including more letters than a-z was quite useful. Perl itself is that way, after all. Sure, you could write (?a:\d) but that's just longer and less clear (and less portable).

      So I suspect I'll be sticking with [0-9] for quite a while still.

      * No, Unicode doesn't actually include Klingon (yet, anyway).

      - tye