Here's something which generates a regex that matches most shrinkable
strings.

print join"|",map{"$_.*[^$_-z]"}('a'..'z')
which prints out:
a.*[^a-z]|b.*[^b-z]|c.*[^c-z]|d.*[^d-z]|e.*[^e-z]|f.*[^f-z]|g.*[^g-z]|h.*[^h
-z]|i.*[^i-z]|j.*[^j-z]|k.*[^k-z]|l.*[^l-z]|m.*[^m-z]|n.*[^n-z]|o.*[^o-z]|p.
*[^p-z]|q.*[^q-z]|r.*[^r-z]|s.*[^s-z]|t.*[^t-z]|u.*[^u-z]|v.*[^v-z]|w.*[^w-z
]|x.*[^x-z]|y.*[^y-z]|z.*[^z-z]

or:
print join"|",map{"$_.*[a-$_]"}('a'..'y')
which prints out:
a.*[a-a]|b.*[a-b]|c.*[a-c]|d.*[a-d]|e.*[a-e]|f.*[a-f]|g.*[a-g]|h.*[a-h]|i.*[
a-i]|j.*[a-j]|k.*[a-k]|l.*[a-l]|m.*[a-m]|n.*[a-n]|o.*[a-o]|p.*[a-p]|q.*[a-q]
|r.*[a-r]|s.*[a-s]|t.*[a-t]|u.*[a-u]|v.*[a-v]|w.*[a-w]|x.*[a-x]|y.*[a-y]|z.*
[a-z]

Basically, it looks for a case of where there is a letter less than the
beginning letter, later in the string. Both assume only a-z letters in the
target string.

Unfortunately, I can't see a way to extend it further to properly
match/notmatch the cases where the string begins with "a" and has an "a"
later as well. The first one doesn't match these types of strings, whereas
the second always matches such strings. While I can think of some solutions
that match a second character, I'm unfortunately unable to extend this to
'n' characters (without knowing the length of the string when generating the
regex), and I'm unable to have it correctly handle 'wraparound' as in the
case of 'aba' as mentioned in a different thread.

I'm just throwing this out there in case anyone holds any puzzle pieces that
connect to mine. :)

Mike Lambert

Reply via email to