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.
文字列「MachineABC」と「MachineABCTest」のみに一致する正規表現が必要です。
次のような表現を試みました: MachineABC["Test"]*. しかし、期待どおりに機能していません。このシナリオに適した正規表現は何ですか?
私はgrepユーティリティでテストしていました。例: echo "MachineABCTest" | grep 'MachineABC["テスト"]+'. 例 grep は null を返します。
その正規表現は次のようになります。
^MachineABC(Test)?$
一部をオプションにしたい場合は、それを?notifier でグループ化してオプションにします (1 つまたは 0 つの一致)。
?
egrep を使用したテスト:
echo "MachineABCTest" | egrep '^MachineABC(Test)?$' MachineABCTest echo "MachineABC" | egrep '^MachineABC(Test)?$' MachineABC