Best way to isolate values to the sixth "/" found in the cell (Google Sheets)

43 views Asked by At

Let's say I have the following values in the cells in COLUMN A:

https://test/one/two/three/four/oliver/Safira
https://five/six/seven/eight/nine/Twix
https://show/the/text/again/please/Isolate/arrows/Sheets

And I would like to isolate the values that come up to the sixth time the "/" is found:

https://test/one/two/three/
https://five/six/seven/eight/
https://show/the/text/again/

I know I could go removing the values every time the / came up with the RIGHT and LEFT + FIND + LEN functions.

But this way the formula is very long, because I would have to isolate / after /. Is there a simpler way to do this?

1

There are 1 answers

5
Tanaike On BEST ANSWER

How about this sample formula? Please think of this as just one of several possible answers.

Sample formula:

=JOIN("/",QUERY(SPLIT(A1,"/",TRUE,FALSE),"Select Col1,Col2,Col3,Col4,Col5,Col6"), "")
  • Split the URL with / with SPLIT.
  • Retrieve the columns 1 to 6 from the splitted URL with QUERY.
  • Join the retrieved values with /.

Result:

enter image description here

References:

If this was not the direction you want, I apologize.

Edit:

When you want to retrieve the values with one formula, how about the following formula? I think that there are several answers. So for this, also please think of this as just one of several possible answers.

Sample formula:

=ARRAYFORMULA(REGEXEXTRACT(A1:A6,REGEXREPLACE(A1:A6,"(https?:\/\/([\w.-]+\/){4})","($1)")))

Result:

enter image description here