JackYaYo
JackYaYo

Reputation: 1

regex matching not correctly in VB.NET

I am trying to get specific string using regex in VB.NET.
Below is my code

The number 8538 is what I want.
However, I can only get full string, {"pushToken":"8538"} , which is not what I want.

Please tell my what I am doing wrong.
Thanks a lot.

Dim pushToken As String = "{""pushToken"":""8538""}"
Dim pattern = "{""pushToken"":""(.*)""}"
Dim match As Match = Regex.Match(pushToken, pattern)
pushToken = match.Value

Upvotes: 0

Views: 73

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

match.Value would print the matched string only, in-order to print the chars which are at the group index 1, you need to call match.Groups(1).Value

pushToken = match.Groups(1).Value

Upvotes: 1

Related Questions