ドキュメント内でダブル ワードを検索する必要があるとします。これを行う方法は次のとおりです。
\b(\w+)\s+\1\b
そして、ここに解剖学があります:
<!--
\b(\w+)\s+\1\b
Options: ^ and $ match at line breaks
Assert position at a word boundary «\b»
Match the regular expression below and capture its match into backreference number 1 «(\w+)»
Match a single character that is a “word character” (letters, digits, and underscores) «\w+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match a single character that is a “whitespace character” (spaces, tabs, and line breaks) «\s+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the same text as most recently matched by capturing group number 1 «\1»
Assert position at a word boundary «\b»
-->
グループ番号を呼び出すことは、パターン内の前のグループを呼び出す/含める唯一の方法です。この半分を願っています。こちらを参考にご覧ください。