Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #377 Case-insensitive string equality

Set the boolean ok to true if the string s is the same as the string t, ignoring case considerations, or to false otherwise.

Two strings are considered equal ignoring case if they are of the same length and corresponding characters in the two strings are equal ignoring case.

import "strings"
ok := strings.EqualFold(s, t)
boolean b = s.equalsIgnoreCase(t);
SysUtils
ok := CompareText(s,t) = 0;
b = s.casefold() == t.casefold()

New implementation...
< >
programming-idioms.org