"_anim\(\d+\)$"
Ok, with that, I can check for any string that has the _anim
suffix alright.
But I need to get t开发者_开发问答he value inside the parenthesis (which I expect to be an integer). And I will also need to get the value before the _anim prefix (which I expect to be a string).
That is what I don't get: how do it "get" values, instead of just "knowing" there was a match?
This is done by putting things into capture groups. in regex these are defined by parentheses, which is why you have to escape them in your regex above, i assume, since you want to check for actual parentheses.
capture groups can be accessed by a number in the order they appear.
Dim ResultString As String
Try
ResultString = Regex.Match(SubjectString, "(.*)_anim\((\d+)\)$").Groups(1).Value
Catch ex As ArgumentException
'Syntax error in the regular expression
End Try
0 would be the entire match, 1 would be the stuff before _anim and 2 would be your digits in this case.
精彩评论