Hi Bakul,
Forgot to add, you can solve this another way (taking
the abc
example):
grep ‘^...$’ | grep ‘[^a]*a[^a]*’ | grep ‘[^b]*b[^b]*’ | grep ‘[^c]*c[^c]*’
I know you know this and the error is just from typing an email, but in
case other listeners are following along, all the greps need start and
end-of-line anchors.
Without them,
grep '[^a]*a[^a]*'
still matches ‘aa’ because there are zero non-a before the first a, then
the first a matches, and there are zero non-a after it. Here's ‘aa’
with indexes between the characters.
a a
0 1 2
[^a]* matches 0-0
a matches 0-1
[^a]* matches 1-1
And it's easier to invert the test into
grep -v 'a.*a'
I'll stop waffling on about regexps now. Though I do have a SNOBOL4
question for TUHS which I should get around to writing. :-)
--
Cheers, Ralph.