Add spaces to string using it's capital / upper case letters


I was wondering if anyone knows a way to add spaces to a string by finding it’s capital letter and then moving the next portion with a single space.
The part where I’m stuck is how to find a capital letter / upper case letter.

Anyone have any ideas?


Hey there,

This is kind of messy but it works

So first we take the input string and make two separate arrays, one as it is, and one as all lowercase, using the Get Character Array from String function.
Then we for loop through the original array, and we check each character (array element) against the same character (array element) of the lower case string (It’s important to use the String == String and not the Case Insensitive version of the same node) If False, we know we have run into a capital character, so in that case, we add a new array element to the array of “Individual Words”, and we set the “Individual Word Number” integer to the index that we just added to the array. Then for every character that IS = to the other character, we know we have found a lower case character, so append that character to the same array element we just added, until we find another capital letter, and then start the process again. When the loop is completed, we join all those individual words from the array, into one string, with the separator of just a blank character, and print it.

Now it’s worth noting that this currently wont work if your first character is not a capital letter. Ill have to think a little more about how to deal with that case, but I hope this gets you started


EDIT: I added a little bit of logic to account for your first letter not being capital Here:
if you needed to capitalise your first letter you could just do a to upper node

1 Like

I made a typewriter widget that printed individual characters one at a time and the method I used to determine which character to print from a string was to just create an “Alphabet” string to compare. Within that string I listed every letter in upper and lower case along with any other symbols I wanted like periods, exclamation, question marks etc. I then took an input string, turned that into an array using the “get character array from string” function and then used a “For each loop with break” to loop through my alphabet string array comparing it to each character in the input string. This finds capital and lowercase letters with one array. To print, I had a “text variable” that contained the “built” characters. Each time a character was identified I appended it to the “built text” and “set the built text” so this variable grew each time a character was found. In your case you would just print the whole thing at the end when it was completed. As for finding “spaces” a “space” is technically a character so if you leave a “space” within your reference string which in my case was the “alphabet” string, then during the loop process it will pick up a “space” as a character and compare it to your input string so whenever you have a space in the input string it will add a space to the “built text”. No need to “append” a space in there by finding capital letters :slight_smile:

Get-Character-As-Number appears to returns ASCII codes when a character is supplied.
So another approach without needing a reference array is just check between 65 and 90.
Edit: But it might not be as useful if you’re likely to face localization issues later on though…

I was going to say “-Use RegEX like this…”,
​​​​​ but then I noticed this is about Blueprints ^^

Thank you all for the help! I will try it out. :slight_smile: