is there a way to convert "my house" to "My House" ?

Post your questions and help other users.

Moderator: Martin

joeko
Posts: 34
Joined: 17 Jan 2017 19:21

Re: is there a way to convert "my house" to "My House" ?

Post by joeko » 08 Feb 2017 19:40

perfekt :-)
many thx for your help :-)

i dont know how this works but it works :-)

if you want to explain it so that i also understand it.....

User avatar
fagci
Posts: 80
Joined: 03 Feb 2017 13:06
Location: Novosibirsk, RU
Contact:

Re: is there a way to convert "my house" to "My House" ?

Post by fagci » 09 Feb 2017 13:46

Code: Select all

regexp = '(?<=\\W)|(?=\\W)'; // expression to get the parts of overall text (including words and spaces)

words = split(text, regexp); // split text by expression

result = ''; // make buffer

for(word in words) { // loop over each part of text

  firstLetter = toUpperCase(left(word,1)); // get first 1 symbol from left side of "word" and uppercase it

  rest = toLowerCase(substring(word,1)); // get rest of the "word" and lowercase it for your needs (tEsT -> Test)

  result = "{result}{firstLetter}{rest}"; // concatenate previous buffer, first letter and the rest to get overall string pretty formatted for your needs

}

log(text);
log(result);
All systems nominal.

Post Reply