利用正则表达式分组替换信息:
源数据 :小明 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 >)。有关更多信息,请参见替换一个命名组 |
$$ | 包括一个“$”文字替换字符串。有关更多信息,请参见“$”符号代替。 |
$& | 包括整个副本替换字符串匹配。有关更多信息,请参见替换整个匹配。 |
$` | 包括所有的文本输入字符串替换字符串的匹配之前。有关更多信息,请参见替换之前的文本匹配。 |
$’ | 包括所有的文本输入字符串替换字符串的匹配之后。有关更多信息,请参见替换后的文本匹配。 |
$+ | 包括最后一批被替换字符串。有关更多信息,请参见替换最后捕获组。 |
$_ | 包括整个输入字符串替换字符串。有关更多信息,请参见替换整个输入字符串。 |