How find a pattern

Rock_4_ever

Member
Joined
Sep 16, 2009
Messages
5
Programming Experience
Beginner
Hi,

i got this var:

dim myvar as string
myvar = "Console.Writeline('Allo')"

i want get text between the ( and ).

I want get 'Allo' with the '

I want extract the code with ' ' because if i get
myvar = "Console.Writeline('Salut ' & any-var)

i want get " 'Salut ' & any-var "


Thx alot!


(Someone know how insert this ==>"<== into a var ? In PHP i use \" ex:
myvar = "Console.Writeline(\"hii\")"

but didnt work in vb net, how do it ?)

Thx again!
 
Using Regex this will get your substring:
VB.NET:
 Import System.Text.RegularExpressions
Dim m As Match = Regex.Match("Console.Writeline('Allo')", "'\w*'")
 ' the string is in m.Value = 'Allo'
And this will get you a " in a variable:
VB.NET:
 Dim chr As Char = Convert.ToChar(148)
 
Last edited:
Back
Top