cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Get the free JMP Student Edition for qualified students and instructors at degree granting institutions.
Choose Language Hide Translation Bar
View Original Published Thread

Case Insensitive searches

Hegedus
Level IV

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?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Craige_Hales
Super User


Re: Case Insensitive searches


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

Craige

View solution in original post


Re: Case Insensitive searches

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") );

 

View solution in original post

5 REPLIES 5
Craige_Hales
Super User


Re: Case Insensitive searches


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

Craige


Re: Case Insensitive searches

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") );

 

tim_reeves
Level III


Re: Case Insensitive searches

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.

Craige_Hales
Super User


Re: Case Insensitive searches

more information on case and regex: Back Reference

Craige
ErraticAttack
Level VI


Re: Case Insensitive searches

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
Jordan