[英]Regular Expression extract substring (.)*
I am trying to match with the following regex. 我正在尝试与以下正则表达式匹配。
\d{11}(.*)
Which is any 11 digits followed by a string. 任意11位数字后跟一个字符串。 I want to extract the tailing string whatever it is.
我想提取尾随字符串,无论它是什么。
I used RE2::FullMatch but it gives the first half (the 11 digits). 我使用了RE2 :: FullMatch,但是它给出了前半部分(11位数字)。 How to get the sub-string matched with
(.*)
? 如何获得与
(.*)
匹配的子字符串?
string subStr
RE2::FullMatch("<sip:+19073381121@216.67.108.201:5060;user=phone>;npi=ISDN",(<sip:\+(\d{11}))(.*), &subStr);
I am trying to extract everything starting from @ in above string. 我正在尝试提取上述字符串中从@开头的所有内容。 Basically I want what matches to (.*) but the above function returns
<sip:+19073381121
. 基本上我想要匹配(。*)的东西,但是上面的函数返回
<sip:+19073381121
。
I am not very familiar with regex but I looked at different APIs to extract substrings and found this one usefull 我对正则表达式不是很熟悉,但是我查看了各种API来提取子字符串,发现这一点很有用
从正则表达式中删除多余的捕获组。
<sip:\+\d{11}(.*)
To get the sub string matched with (.*) use $1. 要使子字符串与(。*)匹配,请使用$ 1。 That is the first capturing group that you specified with the brackets.
这是您使用方括号指定的第一个捕获组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.