Splitting a string in Google Spreadsheet

Here is how to split a string into tokens, then grab each token for each column in Google Spreadsheet.

So we start with the string.

splitting_in_trix_1

Then we do =index(split(A2, ” “), 1, 1). Basically, split will give us an array (or range). Then we select the first row (there is just one resulting row), and we select the first column (there are 3 resulting columns in our example).

splitting_in_trix_2

Similarly we do =index(split(A2, ” “), 1, 2) to pick the second token.

splitting_in_trix_3

Lastly do =index(split(A2, ” “), 1, 3) to pick the 3rd token.

splitting_in_trix_4

This is similar to explode in PHP, and string split in Python. =)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s