Split text into an array of characters

Hi all, I’m new to using Make, and I’ve been having trouble with this.

What I’m trying to do is take some text, split it into each individual character and add those characters to an array. It should also check if the text includes letters or numbers, and keep those instances together in the array.

So something like:

@$#%&*(
Geronimo
$%^&
62487

Should end up as:

[@,$,#,%,&,*,(,Geronimo,$,%,^,&,62487]

1 Like

You can use a combination of regular expressions and string manipulation:

  1. Use a regular expression to match individual characters, letters/words, and numbers:

    (\w+|\d+|.)
    

    This regex pattern will match:

    • \w+: One or more word characters (letters)
    • \d+: One or more digits
    • .: Any single character that doesn’t match the above
  2. Apply this regex to your input text using the “Replace” function in Make:

    • Text: Your input text
    • Pattern: (\w+|\d+|.)
    • Replace with: |$1
    • Global match: Yes
  3. The result will be a string with your desired elements separated by “|” characters.

  4. Use the “Split” function to convert this string into an array:

    • Text: The result from step 2
    • Separator: |
    • Limit: Leave empty

This approach will give you an array that keeps letters and numbers together while separating other individual characters. For your example input, the resulting array would be:

["@", "$", "#", "%", "&", "*", "(", "Geronimo", "$", "%", "^", "&", "62487"]

The first element of the array will be empty due to the leading “|” added in step 2, so you may need to remove it using the “Remove item from array” function if necessary.

1 Like

Thank you so much. That all seems to have worked, although the next module doesn’t recognize it as an array? Even though I can see from the output that an array was generated. This is the error I’m getting: “The operation failed with an error. [400] Invalid parameter ‘searchStrings’ value “the, !, _, -, $, then”: Must be an array of any type.”