2

Convert string to array of words

Hi Klipfolio!

This shows how to convert a string to an array of the words in the string.
This is similar to the PHP explode function, or the JavaScript split function.

ARRAY(
     SUBSTITUTE(
          "Word1,Word2;Word3 Word4", //String to convert
          ARRAY(" ",";","/","."), //word seperators
           ","
      )
)


Hope this helps out!

Warm regards,
Joshua
_____________________________
Joshua Cohen-Collier
Technical Support Engineer, Klipfolio

1 comment

  • 1
    Avatar
    Leann Lewis

    I found this post because I needed to do this across an entire column of data. I have a data source in which one column houses a comma separated list of unique IDs. Some items have multiple IDs:

     

    Wrapping the "array" function around a set of data like this doesn't parse the information within each cell into an array (which makes sense). So for anyone else needing to do this, just use "join" to link the data in the column into a single comma separate item, then cast it as an array to split it back up by comma and use "trim" to remove the white spaces:

     

    If you don't have a trailing comma at the end of your field you can always add one in with "concat" so that you can still join the data. 

     

Please sign in to leave a comment.