cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-778565%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EComment%20rendre%20Regex%20insensible%20%C3%A0%20la%20casse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778565%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESalut.%20Quelqu'un%20conna%C3%AEt-il%20la%20meilleure%20fa%C3%A7on%20de%20rendre%20une%20recherche%20d'expression%20r%C3%A9guli%C3%A8re%20insensible%20%C3%A0%20la%20casse%20en%20JSL%26nbsp%3B%3F%20Par%20exemple%2C%20je%20souhaite%20extraire%20l'extension%20de%20fichier%20d'un%20nom%20de%20chemin%2C%20et%20je%20ne%20veux%20pas%20que%20cela%20importe%20si%20l'extension%20est%20%22.csv%22%20ou%20%22.CSV%22%20ou%20%22.cSv%22.%20Si%20j'essaie%20ce%20qui%20suit%2C%20cela%20ne%20fonctionnera%20que%20sur%20les%20noms%20de%20fichiers%20dont%20les%20extensions%20sont%20en%20minuscules%26nbsp%3B%3A%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Efilename%20%3D%20Regex(path%2C%20%22(.%2B%5C%2F)*(%5B%5E%5C%2F%5D%2B)%5C.(csv%7Cxlsx)%24%22%2C%20%22%5C2%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%20%3C%2FP%3E%3CP%3EUne%20m%C3%A9thode%20consiste%20simplement%20%C3%A0%20convertir%20l'int%C3%A9gralit%C3%A9%20du%20chemin%20en%20minuscules%20avant%20d'y%20appliquer%20une%20expression%20r%C3%A9guli%C3%A8re%2C%20mais%20pour%20diverses%20raisons%2C%20je%20ne%20veux%20pas%20le%20faire.%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Efilename%20%3D%20Regex(LowerCase(path)%2C%20%22(.%2B%5C%2F)*(%5B%5E%5C%2F%5D%2B)%5C.(csv%7Cxlsx)%24%22%2C%20%22%5C2%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%20%3C%2FP%3E%3CP%3EL'autre%20m%C3%A9thode%20que%20j'ai%20essay%C3%A9e%20consiste%20%C3%A0%20utiliser%20le%20modificateur%20%22(%3Fi)%22%20dans%20la%20cha%C3%AEne%20de%20correspondance%2C%20mais%20j'obtiens%20une%20erreur%26nbsp%3B%3A%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Efilename%20%3D%20Regex(path%2C%20%22(%3Fi)(.%2B%5C%2F)*(%5B%5E%5C%2F%5D%2B)%5C.(csv%7Cxlsx)%24%22%2C%20%22%5C2%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%22regex%20a%20trouv%C3%A9%20un%20quantificateur%20*%2C%20%2B%2C%20%3F%20ou%20%7B%3CSPAN%20class%3D%22%22%3E%20%20%3C%2FSPAN%3Edans%20une%20position%20invalide%2C%20le%20r%C3%A9sultat%20n'est%20pas%20d%C3%A9fini%20lors%20de%20l'acc%C3%A8s%20ou%20de%20l'%C3%A9valuation%20de%20'Regex'%22.%20Je%20suppose%20que%20ce%20modificateur%20n'est%20pas%20pris%20en%20charge%20dans%20JSL.%20Des%20id%C3%A9es%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-778565%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3EAutomatisation%20et%20scripts%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-778590%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%20%3A%20Comment%20rendre%20Regex%20insensible%20%C3%A0%20la%20casse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778590%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3ESi%20vous%20souhaitez%20extraire%20l'extension%20de%20fichier%2C%20je%20vous%20sugg%C3%A8re%20de%20consulter%20les%20fonctions%20Word()%2C%20Words()%2C%20Item()%20et%20Items()%20au%20lieu%20d'utiliser%20Regex.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-778768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%20%3A%20Comment%20rendre%20Regex%20insensible%20%C3%A0%20la%20casse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EIl%20y%20a%20aussi%20l'indicateur%20IGNORECASE%20dans%20Regex%20dans%20JMP%2C%20mais%20je%20sugg%C3%A9rerais%20quand%20m%C3%AAme%20d'utiliser%20d'autres%20m%C3%A9thodes%20que%20regex%20si%20vous%20voulez%20juste%20le%20nom%20de%20fichier%20(ou%20l'extension%20ou%20les%20deux)%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Apath%20%3D%20Convert%20File%20Path(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0Afilename1%20%3D%20Regex(path%2C%20%22(.%2B%5C%2F)*(%5B%5E%5C%2F%5D%2B)%5C.(JMP)%24%22%2C%20%22%5C2%22%2C%20IGNORECASE)%3B%0Afilename2%20%3D%20Word(-2%2C%20path%2C%20%22%5C%2F.%22)%3B%0Afilename3%20%3D%20Word(-1%2C%20path%2C%20%22%5C%2F%22)%3B%0A%0AShow(filename1%2C%20filename2%2C%20filename3)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22jthi_0-1722668744463.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1722668744463.png%22%20style%3D%22width%3A%20845px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1722668744463.png%22%20style%3D%22width%3A%20845px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1722668744463.png%22%20style%3D%22width%3A%20845px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22jthi_0-1722668744463.png%22%20style%3D%22width%3A%20845px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F66800iFF6D7C2200A6AFDF%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22jthi_0-1722668744463.png%22%20alt%3D%22jthi_0-1722668744463.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F18.0%2F%23page%2Fjmp%2Fcharacter-functions-2.shtml%3Fos%3Dwin%26amp%3Bsource%3Dapplication%23ww4813286%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ERegex(source%2C%20mod%C3%A8le%2C%20(%3C%2FA%3E%3CREPLACEMENT%20string%3D%22%22%3E%20%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F18.0%2F%23page%2Fjmp%2Fcharacter-functions-2.shtml%3Fos%3Dwin%26amp%3Bsource%3Dapplication%23ww4813286%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%2C%3C%2FA%3E%3CFORMAT%3E%20%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F18.0%2F%23page%2Fjmp%2Fcharacter-functions-2.shtml%3Fos%3Dwin%26amp%3Bsource%3Dapplication%23ww4813286%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%26gt%3B)%3C%2FA%3E%3C%2FFORMAT%3E%3C%2FREPLACEMENT%3E%20%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F18.0%2F%23page%2Fjmp%2Fregex-function.shtml%23ww436102%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGuide%20de%20script%20%26gt%3B%20Types%20de%20donn%C3%A9es%20%26gt%3B%20Expressions%20r%C3%A9guli%C3%A8res%20%26gt%3B%20Fonction%20Regex%3C%2FA%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-778805%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3ERe%20%3A%20Comment%20rendre%20Regex%20insensible%20%C3%A0%20la%20casse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778805%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CP%3ECe%20code%20hybride%20fonctionne%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Apath%20%3D%20%22C%3A%5Cusers%5Cbig.cSv%22%3B%0Afilename%20%3D%20%22%22%3B%0Aext%20%3D%20Word(%20-1%2C%20path%2C%20%22.%22%20)%3B%0AIf(%20Uppercase(%20ext%20)%20%3D%3D%20%22CSV%22%20%7C%20Uppercase(%20ext%20)%20%3D%3D%20%22XLSX%22%2C%0A%09filename%20%3D%20Eval(%0A%09%09Parse(%0A%09%09%09%22Regex(path%2C%20%5C!%22(.%2B%5C%2F)*(%5B%5E%5C%2F%5D%2B)%5C.%22%20%7C%7C%20ext%20%7C%7C%20%22%24%5C!%22%2C%20%5C!%22%5C2%5C!%22)%22%0A%09%09)%0A%09)%0A)%3B%0AShow(%20filename%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EMon%20JSL%20pr%C3%A9f%C3%A9r%C3%A9%20est%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Apath%20%3D%20%22C%3A%5Cusers%5Cbig.cSv%22%3B%0Afilename%20%3D%20%22%22%3B%0Aext%20%3D%20Word(%20-1%2C%20path%2C%20%22.%22%20)%3B%0AIf(%20Uppercase(%20ext%20)%20%3D%3D%20%22CSV%22%20%7C%20Uppercase(%20ext%20)%20%3D%3D%20%22XLSX%22%2C%0A%09filename%20%3D%20Word(%20-2%2C%20path%2C%20%22.%5C%2F%22%20)%0A)%3B%0AShow(%20filename%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-779433%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20Comment%20rendre%20les%20expressions%20r%C3%A9guli%C3%A8res%20insensibles%20%C3%A0%20la%20casse%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-779433%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EMerci%20%3CA%20href%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F14366%22%20target%3D%22_blank%22%3E%40jthi%3C%2FA%3E%20.%20Je%20savais%20que%20j'avais%20vu%20%C3%A7a%20quelque%20part.%20Bien%20s%C3%BBr%2C%20c'%C3%A9tait%20dans%20le%20guide%20de%20script.%20Ha.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
nikles
Level VI

How to make Regex case insensitive

Hi.  Does anyone know the best way to make a regex search case insensitive in JSL?  For example, I wish to extract the file extension from a path name, and I don't want it to matter if the extension is ".csv" or ".CSV" or ".cSv".  If I try the following, it will only work on filenames whose extensions are lowercase:

 

filename = Regex(path, "(.+\/)*([^\/]+)\.(csv|xlsx)$", "\2")

 

One method is to just convert the entire path to lowercase before doing regex on it, but for various reasons I don't want to do that.  

 

filename = Regex(LowerCase(path), "(.+\/)*([^\/]+)\.(csv|xlsx)$", "\2")

 

The other method I tried is to use the "(?i)" modifier in the match string, but I get an error:

filename = Regex(path, "(?i)(.+\/)*([^\/]+)\.(csv|xlsx)$", "\2")

"regex found a quantifier *, +, ?, or {  in an invalid position, the result is undefined in access or evaluation of 'Regex'".  I'm guessing that modifier is not supported in JSL.  Any ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to make Regex case insensitive

There is also IGNORECASE flag in Regex in JMP, but still I would suggest using other methods than regex if you just want the filename (or extension or both)

Names Default To Here(1);

path = Convert File Path("$SAMPLE_DATA/Big Class.jmp");
filename1 = Regex(path, "(.+\/)*([^\/]+)\.(JMP)$", "\2", IGNORECASE);
filename2 = Word(-2, path, "\/.");
filename3 = Word(-1, path, "\/");

Show(filename1, filename2, filename3);

jthi_0-1722668744463.png

Regex(source, pattern, (<replacement string>, <format, "GLOBALREPLACE", "IGNORECASE">>)

Scripting Guide > Types of Data > Regular Expressions > Regex Function 

-Jarmo

View solution in original post

4 REPLIES 4
jthi
Super User

Re: How to make Regex case insensitive

If you wish to extract file extension I would suggest checking out Word(), Words(), Item() and Items() functions instead of using Regex.

-Jarmo
jthi
Super User

Re: How to make Regex case insensitive

There is also IGNORECASE flag in Regex in JMP, but still I would suggest using other methods than regex if you just want the filename (or extension or both)

Names Default To Here(1);

path = Convert File Path("$SAMPLE_DATA/Big Class.jmp");
filename1 = Regex(path, "(.+\/)*([^\/]+)\.(JMP)$", "\2", IGNORECASE);
filename2 = Word(-2, path, "\/.");
filename3 = Word(-1, path, "\/");

Show(filename1, filename2, filename3);

jthi_0-1722668744463.png

Regex(source, pattern, (<replacement string>, <format, "GLOBALREPLACE", "IGNORECASE">>)

Scripting Guide > Types of Data > Regular Expressions > Regex Function 

-Jarmo
txnelson
Super User

Re: How to make Regex case insensitive

This hybrid code works 

Names Default To Here( 1 );
path = "C:\users\big.cSv";
filename = "";
ext = Word( -1, path, "." );
If( Uppercase( ext ) == "CSV" | Uppercase( ext ) == "XLSX",
	filename = Eval(
		Parse(
			"Regex(path, \!"(.+\/)*([^\/]+)\." || ext || "$\!", \!"\2\!")"
		)
	)
);
Show( filename );

My preferred JSL is

Names Default To Here( 1 );
path = "C:\users\big.cSv";
filename = "";
ext = Word( -1, path, "." );
If( Uppercase( ext ) == "CSV" | Uppercase( ext ) == "XLSX",
	filename = Word( -2, path, ".\/" )
);
Show( filename );
Jim
nikles
Level VI

Re: How to make Regex case insensitive

Thanks @jthi .  I knew I'd seen this somewhere.  Of course it was in the scripting guide.  Ha.

Recommended Articles