Hi,
Most JMP is case insensitive except when it comes to text values.
Since text data is often messy and case is one way it shows up, is there a way to do case insensitive versions of Contains?
regex is case sensitive by default, PatMatch is insensitive by default.
regex("The Quick Brown Fox", "quick", "\0", IGNORECASE); "Quick" regex("The Quick Brown Fox", "quick", "\0"); returns missing rc = PatMatch("The Quick Brown Fox", patPos()>>where + "quick">>what); show(rc,where,what); rc = 1; where = 4; what = "Quick"; PatMatch("The Quick Brown Fox", patPos()>>where + "quick">>what, NULL, MATCHCASE); returns 0
Regex
If you want to specifically use Contains(), you can use Lowercase() or Uppercase() to perform case-insensitive searches:
str1 = "Hello"; str2 = "ELL"; Contains( Lowercase(str1), Lowercase(str2) ); Contains( Lowercase(str1), "ell" ); Contains( Lowercase(str1), Lowercase("Ell") );
more information on case and regex: Back Reference
this was helpful to me and I think it should be mentioned in the Help for the Contains function, which does not even mention that the function is case-sensitive.
If you're trying to find a matching item in a list of strings (say column titles) and you want to match JMP's default of ignoring case / spaces, you can use the As Name function, see below
Names Default to Here( 1 ); list = {"Height", "Weight", "CamelCase", "__Dunder_Mifflin__" }; Show( Contains( list, "camel case" ) ); // 0 named list = {}; For( i = 1, i <= N Items( list ), i++, named list[i] = As Name( list[i] ) ); Show( Contains( named list, As Name( "camel case" ) ) ); // 3