Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
a OR an i を含むすべての行をリストする正規表現コードを探しています。私はこれを試しました:
grep -E '[(a|i)]{1}' testFile.txt
しかし、これにより、a または i を含む単語と en i を含む単語が得られます。どうしたの?
あなたはそれを達成することができます:
grep -E "^[^ai]*(a|i){1}[^ai]*$" testFile.txt
排他的 OR が必要な場合は、これを試してください。 grep -E '^[^i]*a[^i]*$|^[^a]*i[^a]*$'
grep -E '^[^i]*a[^i]*$|^[^a]*i[^a]*$'