Google Sheets – Split Text with Delimiter Containing Spaces

google sheets

I have a column (A) in Google Sheets where each row contains the following string:

"TEXT on MORE_TEXT" or, for more specific example "occurred on December 17, 2020". The "MORE_TEXT" part can be any of the 12 months.

I need to split it so that the "December 17, 2020" is in a separate column and my desired delimiter is " on ", which is a space character followed by the word "on" and then another space.

But when I use =SPLIT(A:A," on ") it ignores the spaces around "on" and I have no other ideas.

I am sure I am about to learn something simple but effective and am looking forward to it.

Best Answer

There are many ways to achieve the result you are looking. Here is one of the oldies, using RIGHT, LEN and FIND

=ArrayFormula(RIGHT(A:A,LEN(A:A) - FIND(" on ",A:A) - 3)

Another way, in this case using SPLIT, SUBSTITUTE and INDEX

=ArrayFormula(INDEX(SPLIT(SUBSTITUTE(A:A," on ","|"),"|"),1,2))

One way using regular expressions

=ArrayFormula(REGEXEXTRACT(A:A," on (.+)"))

P.S. The simplest way to avoid having errors for blanks cells below the las row having a value on A, delete all the bottom blank rows.