Regex to match odd numbers

Gareth Harper spansh+london at gmail.com
Tue May 27 16:59:40 BST 2014


Apologies, didn't see the 7 upward (and missed the 5\.) .  This can almost
certainly look nicer or smaller with a negative assertion or something.
However this should do the job.

$record->{perl} =~ /(^5\.(7|9|[1-9][0-9]*[13579])|rc|patch)/i






On 27 May 2014 16:53, Gareth Harper <spansh+london at gmail.com> wrote:

> $record->{perl} =~ /(^[0-9]*[13579]|rc|patch))/i
>
> ?
>
>
> On 27 May 2014 16:22, David Cantrell <david at cantrell.org.uk> 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.
>>
>> --
>> David Cantrell | Official London Perl Mongers Bad Influence
>>
>> Today's previously unreported paraphilia is tomorrow's Internet sensation
>>
>
>


More information about the london.pm mailing list