Hi Michael,
I was trying to do something very similar using
procmail regexes some
time ago, only with strings instead of individual characters (for
parsing and matching on arbitrarily-ordered, comma-separated values
within a header). I never did come up with a good solution.
Assuming procmail has BRE, this does one interpretation of what you
said.
$ grep '^ *field *: *\(foo\|bar\|xyzzy\)\( *, *\(foo\|bar\|xyzzy\)\)* *$'
<<\E
otherfield: foo
field:
field: ,
field:foo
field : foo
field:xyzzy
field: xyzzy,bar, foo , xyzzy
field: xyzzy,bar, foo , xyzzy ,
E
field:foo
field : foo
field:xyzzy
field: xyzzy,bar, foo , xyzzy
$
If I was doing it in sed, I'd s/$/,/ before and s/,$// after so the list
of alternatives need only be given once with each alternative having to
be followed by a comma, i.e. the comma switches from separator to
terminator.
--
Cheers, Ralph.