正則表示式 分組命名 替換
阿新 • • 發佈:2019-01-30
利用正則表示式分組替換資訊:
源資料 :小明 13800138000 廣東省
目的結果:廣東省 13800138000 小明
匹配:
^(?<name>.*)\t(?<phone>.*)\t(?<address>.*)$
替換:
${address} ${phone} ${name}
sublime text 正則替換(非主流):
$+{address} $+{phone} $+{name}
Substitution | Description |
---|---|
$number | Includes the last substring matched by the capturing group that is identified by number, where number is a decimal value, in the replacement string. For more information, see Substituting a Numbered Group |
${name} | Includes the last substring matched by the named group that is designated by (? ) in the replacement string. For more information, see Substituting a Named Group |
$$ | Includes a single “$” literal in the replacement string. For more information, see Substituting a “$” Symbol. |
$& | Includes a copy of the entire match in the replacement string. For more information, see Substituting the Entire Match. |
$` | Includes all the text of the input string before the match in the replacement string. For more information, see Substituting the Text before the Match |
$’ | Includes all the text of the input string after the match in the replacement string. For more information, see Substituting the Text after the Match |
$+ | Includes the last group captured in the replacement string. For more information, see Substituting the Last Captured Group. |
$_ | Includes the entire input string in the replacement string. For more information, see Substituting the Entire Input String. |
漢化版:
Substitution | Description |
---|---|
$number | 包括最後一子串匹配的捕獲組所識別的號碼,號碼是一個十進位制值,在替換字串。有關更多資訊,請參見替換組編號 |
${name} | 包括最後一子串匹配所指定的命名分組(?< name >)。有關更多資訊,請參見替換一個命名組 |
$$ | 包括一個“$”文字替換字串。有關更多資訊,請參見“$”符號代替。 |
$& | 包括整個副本替換字串匹配。有關更多資訊,請參見替換整個匹配。 |
$` | 包括所有的文字輸入字串替換字串的匹配之前。有關更多資訊,請參見替換之前的文字匹配。 |
$’ | 包括所有的文字輸入字串替換字串的匹配之後。有關更多資訊,請參見替換後的文字匹配。 |
$+ | 包括最後一批被替換字串。有關更多資訊,請參見替換最後捕獲組。 |
$_ | 包括整個輸入字串替換字串。有關更多資訊,請參見替換整個輸入字串。 |