且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何反向引用“内部"正则表达式中的选择 ( () )?

更新时间:2022-11-14 18:46:14

Just use \1 ... \9 (or $1... $9 在某些正则表达式实现中),就像您通常会做的那样.编号是从左到右,基于开放括号的位置(因此嵌套组的编号大于嵌套组的编号).

Just use \1 ... \9 (or $1 ... $9 in some regex implementations) like you normally would. The numbering is from left to right, based on the position of the open paren (so a nested group has a higher number than the group(s) it's nested within).