I need a single-pass regex for unix grep that contains, say alpha, but does not contain beta.
grep \'alpha\' <> | grep -v \'beta\'
I'm pretty sure this isn't possible with true regular expressions. The [^y]*x[^y]*
example would match yxy, since the * allows zero or more non-y matches.
EDIT:
Actually, this seems to work: ^[^y]*x[^y]*$
. It basically means "match any line that starts with zero or more non-y characters, then has an x, then ends with zero or more non-y characters".