April 2016 Archives

Stupid Regexp Trick: Fail on match

I found myself one day trying to come up with a regexp that matched

m/ \G \s* (?:
        (?<oct> 0b[01]+ | 0[0-7]+ | 0x[[:xdigit:]]+ ) |
        (?<float> [+-]?(?=\.?\d)\d*\.?\d*(?:e[+-]?\d+)? )
    (?! \w )

where the <oct> capture represents things that need to be run through the oct built-in, and the <float> capture comes from perlfaq4.

The problem here was t…

About Tom Wyant

user-pic I blog about Perl.