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.
次のコマンドの出力に混乱したとき、sed を使用していくつかのコマンドを練習していました。
echo 'first:second' | sed 's_[^:]*_(&)_g'
私の質問は、このコマンドが文字列「first」と「second」のみを括弧で囲むのはなぜですか?
正規表現条件で「 0個以上の非コロン」を指定したので、コロンもラップするべきではありませんか?
どうか明らかにしてください。
あなたが使う
[^:]
を除くすべての文字を検索します:。したがって、あなたが経験するのは通常の行動です。
: