Fix script to fix upper case/lower case syntax

mdjoseph12
Giga Contributor

Does anyone have a fix script that can make the first letter of a string uppercase and the rest lowercase? 

3 REPLIES 3

Manish Vinayak1
Tera Guru

Could you provide details about the table involved, the field where you want to make the first letter uppercase and rest lowercase?

The basic script to do something like that is as follows:

 

var str = "test";
//Making sure that everything is converted to lowercase first
str = str.toLowerCase();
//Making the first character uppercase
var newStr = str.charAt(0).toUpperCase() + str.slice(1);

//result for this code -> str: test, newStr: Test

 

But you will need to query the table, get the value from the required table, and then use the above code snippet to convert the string value.

Hope this helps!

Thanks,

Manish

Yogi3
Kilo Guru

Try this code in fix script

 

var string = 'the tiger is in the woods';
gs.print(camelSentence(string));
function camelSentence(str) {
return (" " + str).toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g, function(match, chr)
{
return chr.toUpperCase();
});
}

 

find_real_file.png

Prateek kumar
Mega Sage

Take a look at below.

https://flaviocopes.com/how-to-uppercase-first-letter-javascript/

https://stackoverflow.com/questions/1026069/how-do-i-make-the-first-letter-of-a-string-uppercase-in-...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks