Name

String.toLowerCase( ) Method — generate a lowercase version of a string

Availability

Flash 5

Synopsis

string.toLowerCase( )

Returns

The lowercase equivalent of string as a new string. Characters without a lowercase equivalent are left unchanged.

Description

The toLowerCase( ) method creates a new, lowercase version of string; it can be used for formatting or to facilitate case-insensitive character comparisons. The toLowerCase( ) method converts only characters in the range A-Z (it does not convert characters with diacritical marks such as accents and umlauts).

Usage

Note that toLowerCase( ) does not modify string; it returns a completely new string.

Example

// Set msg to "this sentence has mixed caps!"
msg = "ThiS SenTencE Has MixED CaPs!".toLowerCase( );

// Perform a case-insensitive comparison of two strings
function caseInsensitiveCompare (stringA, stringB) {
  return (stringA.toLowerCase() == stringB.toLowerCase( ));
}

trace(caseInsensitiveCompare("Colin", "colin"));  // Displays: true

See Also

String.toUpperCase( ); Section 4.6.8.2 in Chapter 4

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.