in reply to RegEx Question
Simple approach:
D:\>perl -lne "print /^[0-8]{9}$/ && !/(.)(?=.*\1)/ ? 'ok' : 'not ok'" 1234 not ok 1234567689 not ok 012345678 ok 018273645 ok 010101010 not ok ^Z
And with one regexp:
D:\>perl -lne "print /^(?:([0-8])(?!.*\1)){9}$/ ? 'ok' : 'not ok'" 123456780 ok 123123123 not ok 123456781 not ok ^Z
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: RegEx Question
by Marshall (Canon) on Sep 10, 2009 at 08:01 UTC | |
by grizzley (Chaplain) on Sep 10, 2009 at 12:11 UTC |