Arshanaa
Arshanaa

Reputation: 45

Delete ALL text to the right of a particular character in google spreadsheet

I have the following value in an Google Spreadsheet.

A1  abcd/defg/xyz/abc
A2  ghtht/sdfsd
A3 dsfdsf/sdfsdfa/erere/dfdf/erer/sdfsdfs

What forumla or script should I use that I get

B1 abcd/defg/xyz
B2 ghtht
B3 dsfdsf/sdfsdfa/erere/dfdf/erer

Regards

Upvotes: 1

Views: 8128

Answers (2)

AdamL
AdamL

Reputation: 24619

This will remove the right-most instance of the forward slash, and everything to the right of it:

=REGEXEXTRACT(A1,"^(.*)/[^/]*$")

Upvotes: 1

KRR
KRR

Reputation: 4947

You can use the SPLIT function to parse the string, delete the last cell, and append the string back using CONCATENATE function. Else you can write a script to parse and manipulate the string as you wanted using Apps script, which is just JavaScript. Here is the documentation on how to read and write from Spreadsheets in Appscript.

Hope that helps!

Upvotes: 2

Related Questions