Pick out a string from within a string

leighhobson89

New Member
Joined
Aug 25, 2016
Messages
36
Hi guys,

I am doing a WinHTTPRequest API call. The response is stored in a variable called responseText. Somewhere in that string will be "videoID": "xxxxxxxxxxx"

The objective here is to pull out the 11 "x" characters and write them in a string.

The GET request sample looks exactly like above (although that is just a snippet from a large response), so it includes the quotes and space, and the colon. So I need to find videoID, skip 4 characters, then copy the next 11 into a variable.

Please can someone indicate the code needed to do this?

Thanks.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Try this:
Code:
    Dim x As String, p As Long
    p = InStr(responseText, """videoID"": ") + Len("""videoID"": ")
    x = Mid(responseText, p + 1, 11)
    MsgBox x
 
Upvote 0
Maybe something like this...

ID = Split(Split(ResponseText, """videoID"":")(1), """")(1)
 
Upvote 0
Awesome guys. I went with the first one, and haven't tried the second one as the first one worked. This web-site is awesome! Thanks again!
 
Upvote 0

Forum statistics

Threads
1,216,743
Messages
6,132,457
Members
449,729
Latest member
davelevnt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top