かっこ(グループ)で一部だけ取り出す
この記事のポイント
- かっこ付きのパターンを書く
- 文章を入れる
- グループを見る
正規表現テスター は、一致ごとに、かっこの中身を表示します。
手順
- かっこ付きのパターンを書く
- 文章を入れる
- グループを見る
「(\d+)年(\d+)月」なら、年と月を別々に取り出せます。
正規表現テスターを使う(無料)
あわせて使えるツール
- 2つの文章の違いを調べる:2つの文章の違いを、行ごとに色つきで示します。
- 文字数カウント(エントリーシート・レポート用):文章の文字数・行数・原稿用紙の枚数などを数えます。
- 重複した行を消す・並べ替える:重複した行を消して、並べ替えます。
同じツールの、ほかの解説
Capturing Parts with Parentheses
Key points
- Write a pattern with parentheses
- Enter the text
- See the groups
Regex Tester shows the contents of the parentheses for each match.
Steps
- Write a pattern with parentheses
- Enter the text
- See the groups
A pattern like "(\d+)-(\d+)" pulls out two numbers separately.
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.