I have a string for example CatCook and i am trying to split it by the capital letters. I tried doing this:
local str = ("CatCook"):split("%u")
print(str)
Which %u should split it by the capitals? Or am i completely wrong? It still returns CatCook while i would like it to return Cat Cook. How would i do it?
Thanks, kirda
So apparently i found about using brackets in patterns and created 2 lines method
local str = "ThisWillSplitThisStringBySpacesIThink"
str = string.gsub(str, "(%u)", " %1")
-- using brackets it allows third argument to access it by doing %1 (1 since it's the first bracket) and you can add TO or AFTER the letter instead of chaning it
str = string.sub(str, 2, -1) -- Removes first space (idk how to remove it otherwise)
print(str)
I randomly found similar thing in comma_value converter at the bottom of this

5 comments
Thank you soo much!!! i combined my knowledge with this and now it also works for strings with multiple capital letters
Care to share what you did for that? That was pretty much the next step, and I didn't want to try to give you that information when I was unsure of it, myself.
I have combined the %l%u with basic for loop which fixes %l%u not working for words with 1 letter which made me awesome result, i edited post and there is the script if you would like to see it
Really good job, congrats.
Look at my edited post at the bottom haha, we were trying and it was that easy ^^