Kibi Brat Kibi Brat - 3 months ago 13
Vb.net Question

VB.Net Regex random string

I have regex code that gets string between 2 strings from TextBox1.

TextBox1 looks something like this:

href="www.example.com/account/05798/john123">
href="www.example.com/account/4970/max16">
href="www.example.com/account/96577/killer007">
href="www.example.com/account/3077/hackerboy1337">
href="www.example.com/account/43210/king42">


So, it will get value from
href="www.example.com/account/4321/
to
">
(usernames)



The problem is, how to do it? My regex code:

(?<="href=""www.example.com/account/RANDOM_STRING/")(.*?)(?="">)


I know i could replace
RANDOM_STRING
with
\w{4}
, but some IDs are 5-digit.

Answer

Or another option would be to do this

 Dim strOne As String = "www.example.com/account/43210/king42"
 Dim strMain As String = Split(strOne, "/account/")(1)
 Dim strSubOne As String = Split(strMain, "/")(0)
 Dim strSubTwo As String = Split(strMain, "/")(1)
Comments