Joe Lombardo
Joe Lombardo

Reputation: 31

Extracting Info from URL using Google Sheets

I would like to take a URL and extract characters to multiple cells in Google Sheets.

The format of these URLs are:

https://www.sideshow.com/collectibles/{PRODUCT_NAME}-{PRODUCT_ID}

This is an example of the URL:

I'd like to extract the following to 2 different cells:

The Product Name, marvel-scarlet-witch, will change with every URL but its position in the URL is constant.

I'm not sure if all this can be done in a single action or if two separate ones would be required.

Upvotes: 3

Views: 69

Answers (2)

Srishti Gupta
Srishti Gupta

Reputation: 1273

Assuming that the string is in cell C1.

To extract Product ID from the given URL format, use the formula on A1 cell:

=PROPER(SUBSTITUTE(REGEXEXTRACT(C1,".*/(.*)-sideshow-collectibles"), "-", " "))

To extract Product Name from the given URL format, use the formula on B1 cell:

=RIGHT(C1,6)

Upvotes: 0

JPV
JPV

Reputation: 27262

Alternatively you can also try (assuming string in D1)

=split(proper(substitute(regexreplace(D1, ".*\/(.*?)-side.*?([^-]\d+)$", "$2✓$1"), "-", " ")), "✓")

Change range to suit.

See this link for a brief explanation about the regular expression.

enter image description here

Upvotes: 2

Related Questions