OL Learn

Correct Propercase feature

I need to proper case certain data fields. When applying the proper case format in “edit script”, the result is not correct. The first letter of every work is upper case, when it should be the first word of sentence - see attached. Is there anyway to correct this?

That’s functioning as intended.

The text formatting functions are used on Strings. lowerCase() transform all characters to lowercase, upperCase() transforms all characters to uppercase and properCase() transforms the first character of each word to uppercase and all other characters to lowercase.

You could attempt something similar to what was done here: https://codepen.io/rothkj1022/pen/eNONZz

However, that’s a blind operation and isn’t going to keep Proper Nouns capitalized in the middle of the sentence.

1 Like

Using the following expanded script will capitalize the first letter of all sentences with the remaining letter being converted to lower case. Unfortunately, there is no way for the script to know what constitutes a proper noun or an abbreviation (i.e. is cat an animal or is it the abbreviation for the name Catherine?).

result = result.replace(/.+?[\.\?\!](\s|$)/g, function (txt) {
        return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
    });
results.html(result);
1 Like

Thank you, I appreciate the quick reply.