in reply to Number of bits, length of RegExp
and handle an odd number similarly. It's not a regex, but it should do the job, and it's very short. If you really want to do a regex, try$foo =~ tr/0//d; length($foo);
As you can see, I think your one to match evens is good./^(?:0*10*1)*/ # Matches evens /^0*1(?:0*10*1)*/ # Odds
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Number of bits, length of RegExp
by diotalevi (Canon) on Apr 21, 2003 at 14:58 UTC | |
by Improv (Pilgrim) on Apr 21, 2003 at 15:02 UTC |