OT: simple regex question
Khoa Ton
khoa at puresynergy.com
Mon Apr 23 12:01:26 UTC 2007
Dario Lesca wrote:
> Hi, how to found into string 2 or more word, only if are all present?
>
> % echo "aa bb cc dd"|egrep -q '(bb|dd)' && echo found
>
> This command show "found" if bb OR dd are in string.
> But if I want show "found" only if bb AND dd are present into string.
>
> What egrep (or sed) command I must use?
I know Matt solved this with some impressive perl-fu, but here's a solution
just so grep doesn't feel left out :-)
text="aa bb cc dd"; echo " $text " | egrep -qe '( aa( .+)* dd )|( dd( .+)* aa )' && echo found
Khoa
More information about the users
mailing list