Need some regex help

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
I'm not sure where to begin on this one, but I'm getting a string from a System.Net.WebClient.DownloadString() and what I need is the first match for this part of the string which is: ;sesc=6057eb4ce0b218046467378c73d55ea0"
I need the stuff between the ; and the "
the "6057eb4ce0b218046467378c73d55ea0" could be anything but will always be alphanumeic, no symbols or special chars

One of these days I'll get around to learning RegEx

Edit:
I just noticed that the DownloadString doesn't include links, which the part of the string I need is in a link, any ideas?
 
I'm not the best at it either, but this pattern works
VB.NET:
[FONT="Courier New"]\;([A-Za-z]{4})=([A-Za-z0-9]{32})[/FONT]
It will accept a longer string unless there is a character not specified in th last group ([A-Za-z0-9]{32})
not sure how to set a max, but it won't except a smaller number.
If sesc is the same you can use
VB.NET:
[FONT="Courier New"]\;sesc=([A-Za-z0-9]{32})[/FONT]

How do the chunks come in, any delimiters? Or is your example the chunk size?
 
Last edited:
Further playing, this works too. Especially with a list of your strings (if more than one exists).
VB.NET:
Dim match As MatchCollection = Regex.Matches(<yourString>, ";sesc=(\d\w*)" & Chr(34))
For Each m As Match In match
     lsb.Items.Add(m)
Next
 
Back
Top