Single Regular Expression to identify words with alphabetised characters

Ed Allen era at speedscript.com
Mon Nov 4 14:53:29 CST 2002


 >In article <7qAv9.21$hi7.1683 at paloalto-snr1.gtei.net>, Barry Margolin wrote:
 >> In article <3DBECF72.3BEABE76 at postoffice.pacbell.net>,
 >> Helen Pai  <hpya78 at pacbell.net> wrote:
 >>>How to find words have their letters in alphabetical order?
 >>

 >I eventually managed to find the solution on the web (as I was
 >also interested in it) and I find it much clever:

 >grep '^a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$'

 >Then I searched it on the 20 year archive of comp.unix.shell in
 >groups.google.com but couldn't find any reference to it.

 >Will my post also be cancelled by some obscure force?

This works by only allowing zero or more 'a's first followed by zero
or more 'b's, then 'c's etc.

Characters not present will match zero times but the ones which are
present must be in alphabetic order.

Like these...

abbess
abbey
abbot
abbs
abcee
abcees
abet
abhor
abhors
ablow
ably
abo
abort
abos
abs
abuzz
aby
accent
accept
access
accloy
accost
accoy
ace
acer
acers
aces
ach
achoo
achy




More information about the Kclug mailing list