So i'm trying to make an alias in regex that basically changes all numbers to a color, all lowercase to another color, all uppercase ot another and all ascii to a fourth color.

Code:
alias Themed { 
  var %thm
  %x = $regsub($strip($1-),/([0-9]+)/g,$+($tc(3),\1),%thm)
  %x = $regsub(%thm,/([A-ZÀÁÂÃÄÅÆÇÈÉÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ]+)/g,$+($tc(1),,\1,),%thm)
  %x = $regsub(%thm,/([\\\]\-\^!"#$%,&'()*+.
/:;<=>?@[_`{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“–—˜™š›œžŸ ¡¢£¤¥¦
§¨©«¬­®¯°±²³´µ·¸¹º»¼½¾¿×÷Þßþ]+)/g,$+($tc(4),\1),%thm)
  %x = $regsub(%thm,/([a-zàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ]+)/g,$+($tc(2),\1),%thm)
  return %thm 
}


(Sorry if its a little messy, it turns out a few ascii characters are turning into others x_x. basically the upper case ascii character that are letters with accents (éÉ and such) are considered "Upper" or "Lower" instead of "Ascii", Also i've put the ascii part in three lines just so it doesnt stretch the page, but it's all in one normally.
This is what i have, and so far it works nicely, but there is a little thing that bugs me in it. The Space character (or any invisible characters for that matter) dont count as a character and thus make the script have to re-add a new, totally uneeded color code. ($tc(N) is my "Get the Color code identifier)

Turns for example: HEY into 04HEY, or Hi into 04H14i. But when spaces are involved such as Hey there, it would go 04H14ey 14there. Totally uneeded secondary 14 in there. In more-or-less long messages, that tends to stretch the message length too much.

So, i'm wondering is anyone with more knowledge in Regex could help me actually make spaces "clones" the "type" of the character before it as well as other invisible character so they do not create double unecessary control codes. (and/or clean it up, especially the ascii part)