假设您必须在文档中找到双字,这是如何做到的:
\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»
-->
调用组号只是调用/包含模式中前一个组的方式。希望这一点。请访问此处以供参考。