is there a way to convert "my house" to "My House" ?
Moderator: Martin
is there a way to convert "my house" to "My House" ?
i am looking for an way to convert an variable to uppercase. every word in uppercase.
for example: name = My Name Is Mr Gorden and not my name is mr gordon
and so on. the first word or letter is not a problem but all first letters ?
maybe splitting the variable and convert ?
the numbers of words in this variable is not big but changing from 1 to 5.
someone know a way ?
for example: name = My Name Is Mr Gorden and not my name is mr gordon
and so on. the first word or letter is not a problem but all first letters ?
maybe splitting the variable and convert ?
the numbers of words in this variable is not big but changing from 1 to 5.
someone know a way ?
Re: is there a way to convert "my house" to "My House" ?
Try to make this with replaceAll with some magic pattern or split string to each word and apply toUpperCase() to each first letter, then ccncatenate all words
All systems nominal.
Re: is there a way to convert "my house" to "My House" ?
thx for reply,
replaceall convert every letter ?
can you write here how i split, convert to uppercase and set to a new variable ?
replaceall convert every letter ?
can you write here how i split, convert to uppercase and set to a new variable ?
Re: is there a way to convert "my house" to "My House" ?
Code: Select all
t = 'test text';
r = split(t, '(?<=\W)|(?=\W)');
s = '';
for(word in r) {
s = s + toUpperCase(left(word,1)) + toLowerCase(substring(word, 1));
}
log(t);
log(s);
All systems nominal.
Re: is there a way to convert "my house" to "My House" ?
hi,
thx for help
i tried this code but only the first word is like i need.
the idea is not really clear because i am new in this ...world.
do you know where the bug is in this code ?
what do this "r = split(t, '(?<=\W)|(?=\W)');"
splitting yes but what do the "W" ?
thx for help
i tried this code but only the first word is like i need.
the idea is not really clear because i am new in this ...world.
do you know where the bug is in this code ?
what do this "r = split(t, '(?<=\W)|(?=\W)');"
splitting yes but what do the "W" ?
Re: is there a way to convert "my house" to "My House" ?
All systems nominal.
Re: is there a way to convert "my house" to "My House" ?
i see 
thx for the link and help
but i dont understand enough about it to find the bug in this code...
i get this message after convert from "test text" to "nullTest text"
what i have to change in the code to fix that so that i get "Test Text"?

thx for the link and help
but i dont understand enough about it to find the bug in this code...
i get this message after convert from "test text" to "nullTest text"
what i have to change in the code to fix that so that i get "Test Text"?
Re: is there a way to convert "my house" to "My House" ?
Code: Select all
t = 'test text';
r = split(t, '(?<=\\W)|(?=\\W)');
s = '';
for(word in r) {
p = toUpperCase(left(word,1)) + toLowerCase(substring(word, 1));
log(p);
s = s + p;
}
log(t);
log(s);
All systems nominal.
Re: is there a way to convert "my house" to "My House" ?
great it works 
but the code change also the numbers. is it possible that the numbers stay untouched ?

but the code change also the numbers. is it possible that the numbers stay untouched ?
Re: is there a way to convert "my house" to "My House" ?
Code: Select all
text = 'test text 123eee re456 345';
regexp = '(?<=\\W)|(?=\\W)';
words = split(text, regexp);
result = '';
for(word in words) {
firstLetter = toUpperCase(left(word,1));
rest = toLowerCase(substring(word,1));
result = "{result}{firstLetter}{rest}";
}
log(text);
log(result);
All systems nominal.