Regex to match odd numbers

Abigail abigail at
Tue May 27 16:55:04 BST 2014

On Tue, May 27, 2014 at 04:22:07PM +0100, David Cantrell wrote:
> As part of the nasty mess that is CPANdeps, I have this line of code:
> $record->{is_dev_perl} = (
>   $record->{perl} =~ /(^5\.(7|9|11|13|15|17|19|21)|rc|patch)/i
> ) ? 1 : 0;
> I'd like to not have to remember to add 23 to the list in a year or so's
> time. Can anyone think of a nice way of matching any odd number from 7
> upwards?  Obviously it's easy to do in a coupla lines of perl code
> instead of a regex, so I'm asking more out of curiosity than because I
> actually need it.

You mean, 7, 9, or any number using more than two digits, ending in an
odd one? That doesn't seem to be hard to write.



More information about the mailing list