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 is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
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,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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