2

This should have been simple but I can't find a workaround. I want to split a string into its characters. e.g. dog will be sepearted to: d o g

The problem is I can't put an empty character as a delimiter in the SPLIT function. What am I missing?

TheMaster
  • 45,448
  • 6
  • 62
  • 85
Tom
  • 183
  • 1
  • 3
  • 12
  • The following link includes some answers that might indicate how to do this: https://webapps.stackexchange.com/questions/51648/how-automatically-to-add-spaces-inbetween-each-character-in-a-text-string – underscore_d Apr 23 '21 at 11:12

3 Answers3

6

Also

=ArrayFormula(mid(A1,sequence(1,len(A1)),1))

enter image description here

Tom Sharpe
  • 30,727
  • 5
  • 24
  • 37
3

Something like this ?

=split(regexreplace(A2, "(.)", "$1_"), "_")

or if you'd want an arrayformula to process a column at once

=ArrayFormula(if(len(A2:A), split(regexreplace(A2:A, "(.)", "$1_"), "_"),))

enter image description here

enter image description here

Reference

More info on how this works? Check this link.

JPV
  • 26,499
  • 4
  • 33
  • 48
  • This is great, thanks. Can you please explain how this works? – Tom Apr 23 '21 at 11:33
  • 1
    The regexreplace adds an underscore after every character (that's what the dot means in regular expression). Correcter: it replaces every character with the same character with an added underscore. Then, split is used (with the underscore as delimiter) to create the array of separate characters. – JPV Apr 23 '21 at 12:15
  • Also added some additional info in the answer. – JPV Apr 23 '21 at 12:18
  • Thanks, so (.) represents a character, and $1_ represents adding _ to the character? Why $1 and not (.)_ ? This looks more intuitive – Tom Apr 23 '21 at 12:54
  • 1
    Regular expressions have a specific syntax. To learn more about that syntax, check this link: https://support.google.com/a/answer/1371415?hl=en – JPV Apr 23 '21 at 13:13
1

Try the following

=SPLIT(REGEXREPLACE(O13,"(.)","$1"&"-"),"-",1,1)

enter image description here

marikamitsos
  • 10,264
  • 20
  • 26