Need some more help with RegEx to grab everything between apstrophes.

simpleonline1234

Junior Member
Joined
Jan 26, 2010
Messages
170
Reaction score
13
My app needs to Parse the text to grab only the numbers, letters inside the apstrophes as seen below.
Code:
challenge : '03AHJ_VusHZDEr-qZYnfmRm4QbevEdYMXPLUibIP-bInEgiAPc0tk4e5MAVntRv_JbvD0q51aJOQp1FZ8RmIaMGt-Te9CSwkZyJhvSK70ZvdOA0AhPJz76t1FhXekXWIuor6YqdVwbqXSFlUSQvi9eL455ojSBkoQW_w'
My current string for this is the same as above but my regex to get only the information between these apstrophnes doesn't return a results.
Note that I am trying to get all letters and numbers [a-zA-Z0-9]. My main issue is that the code has random - and _ codes in the challenge.
How can I configure my Regex to just grab anything inside the apstrophes?
thanks
Code:
Sub RegExGet1()

        Dim value As String = "'challenge : '03AHJ_VusHZDEr-qZYnfmRm4QbevEdYMXPLUibIP-bInEgiAPc0tk4e5MAVntRv_JbvD0q51aJOQp1FZ8RmIaMGt-Te9CSwkZyJhvSK70ZvdOA0AhPJz76t1FhXekXWIuor6YqdVwbqXSFlUSQvi9eL455ojSBkoQW_w'"
         Dim m As Match = Regex.Match(ResponseIT.Text, "'challenge : '[a-zA-Z0-9]'", RegexOptions.IgnoreCase)
        If (m.Success) Then
            Dim key As String = m.Groups(1).Value
            KeyIt.Text = (key)
       
        End If
    End Sub
 
you could always try the getstringinbetween function thats floating around.

basically is searches for a given string, inbetween two strings that you set. Ive got one floating around somewhere if you need it, I didnt code it though.
 
First grab the contents between the apostrophes. Second, remove the non-letter and and non-digit characters.
 
Hey Jazzc thanks for the reply..yeah I guess that's kind of my questions what is the RegEx pattern to grab information between apostrophes?. Thanks
 
Code:
Dim ResultString As String
Try    
    ResultString = Regex.Match(SubjectString, "challenge : '(.*?)'").Groups(1).Value
Catch ex As ArgumentException    
    'Syntax error in the regular expression
End Try

Oh, and don't double post threads in different sections :p
 
Sorry Bro..but thank you for the reply Jazzc. Works Great!!
 
Back
Top