我可以在正则表达式搜索中存储捕获的groupe字符串/数字吗?

时间:2016-08-07 16:29:22

标签: regex vb.net

我想将捕获的组内容存储在正则表达式搜索变量

Dim input As String ="asdfd sdf dsf fdsf <disp-formula id=""deqn1-3""> fdsf fds df"
Dim regex As Regex = New Regex("<disp-formula id=""deqn(\d+)-(\d+)"">")
    Dim match As Match = regex.Match(input)
    If match.Success Then
        \\ put the values represented by (\d+) and (\d+) in two variables and then use them in a loop

可以在vb.net中完成吗?如果是这样的话?

1 个答案:

答案 0 :(得分:0)

只需使用match

Groups属性即可
Dim g1 = match.Groups(1).Value ' 1 in your sample
Dim g2 = match.Groups(2).Value ' 3 in your sample