0

I'm trying to set up a formula to extract data from a URL that is in one of the column B of my Google Sheet.

enter image description here

I've been tryin use the LEFT formula to extract the data, but the problem is that the string I am trying to extract can be different in size. I couldn't find a formula that can extract between two substrings.

In this example, I want to pull out the Subreddit which occurs in every URL, after the substring: "https://www.reddit.com/r/" and before the ensuing "/". So the output value for C2 would be "AskReddit".

1
  • Hi, welcome to WebApps. It would be helpful if you included the full URL in your question as plain text. This saves volunteers from having to decipher your screenshot.
    – Tedinoz
    May 20 at 7:30

2 Answers 2

1

Try with this formula in C2:

=index( regexextract(regexreplace(B2:B,"https://www.reddit.com/r/",""),"([^\/]*)"))

REGEX

2
  • Question, why use [/] instead of just \/? Is it just for readability or is there a difference?
    – David Tan
    May 19 at 0:16
  • I changed my mind ... the previous formula could have some problems
    – Daniele
    May 19 at 5:58
0

This is the old-school approach to this problem.

=mid(B2,len("https://www.reddit.com/r/")+1,search("/",B2,len("https://www.reddit.com/r/")+1)-len("https://www.reddit.com/r/")-1)


snapshot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.