in reply to Ideas to improve this regexp?
This seems to work if you don't let the engine give any spaces back by switching off backtracking.
$ perl -le ' > print > qq{->$_<-: }, > m{(?x) ^ (?: \z | (?> \s* ) \D ) } > ? q{matches} > : q{no match} > for q{}, q{12ab}, q{cat}, q{ 99balloons}, q{ dog};' -><-: matches ->12ab<-: no match ->cat<-: matches -> 99balloons<-: no match -> dog<-: matches $
I hope this is of interest.
Cheers,
JohnGG
|
|---|