正規表現で文章をまとめて置換する
この記事のポイント
- パターンを書く
- 置換後の文字を入れる
- 結果をコピー
正規表現テスター の「置換後の文字」を使うと、一致した部分をまとめて書き換えられます。
手順
- パターンを書く
- 置換後の文字を入れる
- 結果をコピー
「$1」は、かっこで囲んだ1番目の部分です。
正規表現テスターを使う(無料)
あわせて使えるツール
- 2つの文章の違いを調べる:2つの文章の違いを、行ごとに色つきで示します。
- 文字数カウント(エントリーシート・レポート用):文章の文字数・行数・原稿用紙の枚数などを数えます。
- 重複した行を消す・並べ替える:重複した行を消して、並べ替えます。
同じツールの、ほかの解説
Replacing Text in Bulk with Regex
Key points
- Write a pattern
- Enter the replacement
- Copy the result
The "Replacement" field in Regex Tester rewrites all matched parts at once.
Steps
- Write a pattern
- Enter the replacement
- Copy the result
"$1" stands for the first parenthesized part.
Use "Regex Tester" (free)
Tools that go well with this
- Compare Two Texts (Diff): Show the differences between two texts line by line.
- Character Counter (for Applications and Reports): Count characters, lines and manuscript sheets of your text.
- Remove Duplicate Lines and Sort a List: Remove duplicate lines and sort them.