Summary of js letter case-insensitive conversion methods

Source: Internet
Author: User

ToLocaleUpperCase Method

Returns a string in which all the letter characters are converted to uppercase and adapted to the current region settings in the host environment.
StringVar. tolocaleUpperCase ()
The required stringVar reference is a String object, value, or text.

Description
The toLocaleUpperCase method converts the characters in the string and adapts to the current region settings in the host environment. In most cases, the results are the same as those obtained using the toUpperCase method. However, if the language rules conflict with the conventional Unicode case-sensitivity ing method, the results will be different.

ToLocaleLowerCase Method

Returns a string in which all letter characters are converted to lowercase, taking into account the current region settings of the host environment.
StringVar. tolocaleLowerCase ()
The required stringVar reference is a String object, value, or text.

Description
The toLocaleLowerCase method converts the characters in the string and adapts to the current region settings in the host environment. In most cases, the results are the same as those obtained using the toLowerCase method. However, if the language rules conflict with the conventional Unicode case-sensitivity ing method, the results will be different.

ToLowerCase Method

Returns a string in which letters are converted to lowercase letters.
StrVariable. toLowerCase ()
"String Literal". toLowerCase ()

Description
The toLowerCase method does not affect non-letter characters.

The following example demonstrates the effect of the toLowerCase method:
Var strVariable = "This is a STRING object ";
StrVariable = strVariable. toLowerCase ();

After executing the previous statement, the value of strVariable is:
This is a string object

ToUpperCase Method

Returns a string in which all letters are converted to uppercase letters.
StrVariable. toUpperCase ()
"String Literal". toUpperCase ()

Description
The toUpperCase method does not affect non-letter characters.

Example
The following example demonstrates the effect of the toUpperCase method:
Var strVariable = "This is a STRING object ";
StrVariable = strVariable. toUpperCase ();

After executing the previous statement, the value of strVariable is:
THIS IS A STRING OBJECT
Copy codeThe Code is as follows:
Function UpperFirstLetter (str)
{
Return str. replace (// B/w +/B/g, function (word ){
Return word. substring (0, 1). toUpperCase () +
Word. substring (1 );
});

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.