1

I have a simple string : s:10:"char1";s:2:"13";i:1;a:8:, i'd like to match that 13 from inside " ", in PHP i would do something like : /s:\d\d?:\"char1\";s:\d\d?:\"(.*?)\";i:\d\d?;a:\d\d?:/i but i'm not good in vb's match methods,so please give me full example how i can match what i need ( it is possible to be multiple matches (2) ). Thanks

1 Answer 1

1

the regex pattern to put in a Regex .Net object should be :

s\:\d+\:"(\d+)"

in order to identify any pattern s:x:"y" (x and y intended as numeric values) can contain the number y, in your case 13...

It matches all the occurences.

Then passing at the VB level, i'm not so good, i give you a code draft (to verify):

Dim pattern As String = "s\:\d+\:""(\d+)"""

Dim input as String = .......

For Each match As Match In Regex.Matches(input, pattern, RegexOptions.IgnoreCase)
         Console.WriteLine("{0} - {1}", _
                           match.Value, match.Groups(1).Value)

match.Groups(1) gives you the number 13 (\d+).

match.Value gives you the whole match value s\:\d+\:"(\d+)".

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.