正则表达式 分组命名 替换

利用正则表达式分组替换信息:
源数据 :小明 13800138000 广东省
目的结果:广东省 13800138000 小明

匹配:

^(?<name>.*)\t(?<phone>.*)\t(?<address>.*)$

替换:

${address}	${phone}    ${name}

sublime text 正则替换(非主流):

$+{address}	$+{phone}   $+{name}
SubstitutionDescription
$numberIncludes 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.

汉化版:

SubstitutionDescription
$number包括最后一子串匹配的捕获组所识别的号码,号码是一个十进制值,在替换字符串。有关更多信息,请参见替换组编号
${name}包括最后一子串匹配所指定的命名分组(?< name >)。有关更多信息,请参见替换一个命名组
$$包括一个“$”文字替换字符串。有关更多信息,请参见“$”符号代替。
$&包括整个副本替换字符串匹配。有关更多信息,请参见替换整个匹配。
$`包括所有的文本输入字符串替换字符串的匹配之前。有关更多信息,请参见替换之前的文本匹配。
$’包括所有的文本输入字符串替换字符串的匹配之后。有关更多信息,请参见替换后的文本匹配。
$+包括最后一批被替换字符串。有关更多信息,请参见替换最后捕获组。
$_包括整个输入字符串替换字符串。有关更多信息,请参见替换整个输入字符串。
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值