Split() won't Split?

I want to take some URLs and chop off all the tracking. I noticed in the URLs the mess comes after the ?

To pull up the book I only need: https://www.audible.com/pd/Daemon-Audiobook/B002V5B9SO

Me thought it clever to split() the array and then take first(). For some reason it won’t split! After question mark wouldn’t work I thought maybe ‘/’ - see below. Thoughts?

Hi @Johg_Ananda,

I’m not able to reproduce it…
What is the actual content of the cell?
Have you tried with Link.toText().Split("/")?

1 Like

@Federico_Stefanato !!! yes it needed to be converted to text. Although I pasted it in as text, Coda did an end run and transformed it into not-text. Thank you! :pray:

Great!
Even though if you need to take out the query parameters, maybe it’s easier go with Left() and Find() functions searching for the “?”.
Unfortunately, RegexReplace() cannot work with groups (please, somebody tell me otherwise); it would have been a good candidate.

Cheers!

Any reason you think left() + find() are better than split() & first()?

Well, just common sense.
I guess that splitting an URL in slashes and taking the first occurrence would return “http:” :grimacing:
You’re not searching for “/” but for “?”, as far as I understood.

If you need a string before a certain string/character, it is usually better search for the occurrence and cut it after.

Does it make sense?

Cheers!

Just realised that perhaps you intended splitting by “?”.
Which does work :upside_down_face:

Ahem :slight_smile:

2 Likes

Well,
thank somebody, then! :smile:

Thanks a lot @Paul_Danyliuk: I actually never dug into that.
Happy to know it does work

1 Like

I get the confusion though, the docs sample clearly specifies $ symbol in the replacement as simply part of the literal $2000. I guess it was just a hunch for me to try \1, %1, $1 — I never remember which that is in this or that language.

Exactly: I just read the formula specs and simply interpolated my understanding from that.

@Codans: Maybe update the example with @Paul_Danyliuk’s one would help to better see the potential.

2 Likes