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!
 

newguy

Well-known member
Joined
Jun 30, 2008
Messages
611
Location
Denver Co, USA
Programming Experience
1-3
Using Regex this will get your substring:
Code:
 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:
Code:
 Dim chr As Char = Convert.ToChar(148)
 
Last edited:

Rock_4_ever

Member
Joined
Sep 16, 2009
Messages
5
Programming Experience
Beginner
THX!

I have search many hour on google for regex and trying to understand it but doesnt...

I understand now thx man!
 
Top Bottom