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%3ESo%20machen%20Sie%20Regex%20gro%C3%9F-%20und%20kleinschreibungsunabh%C3%A4ngig%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778565%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHallo.%20Kennt%20jemand%20die%20beste%20Methode%2C%20um%20bei%20einer%20Regex-Suche%20in%20JSL%20die%20Gro%C3%9F-%2FKleinschreibung%20au%C3%9Fer%20Acht%20zu%20lassen%3F%20Ich%20m%C3%B6chte%20beispielsweise%20die%20Dateierweiterung%20aus%20einem%20Pfadnamen%20extrahieren%20und%20m%C3%B6chte%20nicht%2C%20dass%20es%20eine%20Rolle%20spielt%2C%20ob%20die%20Erweiterung%20%E2%80%9E.csv%E2%80%9C%2C%20%E2%80%9E.CSV%E2%80%9C%20oder%20%E2%80%9E.cSv%E2%80%9C%20lautet.%20Wenn%20ich%20Folgendes%20versuche%2C%20funktioniert%20es%20nur%20bei%20Dateinamen%2C%20deren%20Erweiterungen%20klein%20geschrieben%20sind%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%3EEine%20Methode%20besteht%20darin%2C%20den%20gesamten%20Pfad%20in%20Kleinbuchstaben%20umzuwandeln%2C%20bevor%20man%20regul%C3%A4re%20Ausdr%C3%BCcke%20darauf%20anwendet%2C%20aber%20aus%20verschiedenen%20Gr%C3%BCnden%20m%C3%B6chte%20ich%20das%20nicht%20tun.%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%3EDie%20andere%20Methode%2C%20die%20ich%20ausprobiert%20habe%2C%20besteht%20in%20der%20Verwendung%20des%20Modifikators%20%E2%80%9E(%3Fi)%E2%80%9C%20in%20der%20%C3%9Cbereinstimmungszeichenfolge%2C%20aber%20ich%20erhalte%20eine%20Fehlermeldung%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%20hat%20einen%20Quantifizierer%20*%2C%20%2B%2C%20%3F%20oder%20%7B%20gefunden.%3CSPAN%20class%3D%22%22%3E%20%20%3C%2FSPAN%3Ean%20einer%20ung%C3%BCltigen%20Position%20ist%20das%20Ergebnis%20beim%20Zugriff%20oder%20bei%20der%20Auswertung%20von%20%E2%80%9ERegex%E2%80%9C%20undefiniert.%E2%80%9C%20Ich%20vermute%2C%20dass%20dieser%20Modifikator%20in%20JSL%20nicht%20unterst%C3%BCtzt%20wird.%20Irgendwelche%20Ideen%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%3EAutomatisierung%20und%20Skripting%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%3EBetreff%3A%20Wie%20kann%20man%20bei%20Regex%20die%20Gro%C3%9F-%2FKleinschreibung%20ignorieren%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778590%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWenn%20Sie%20die%20Dateierweiterung%20extrahieren%20m%C3%B6chten%2C%20w%C3%BCrde%20ich%20vorschlagen%2C%20die%20Funktionen%20Word()%2C%20Words()%2C%20Item()%20und%20Items()%20auszuprobieren%2C%20anstatt%20Regex%20zu%20verwenden.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-778768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EBetreff%3A%20Wie%20kann%20man%20bei%20Regex%20die%20Gro%C3%9F-%2FKleinschreibung%20ignorieren%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778768%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EEs%20gibt%20auch%20ein%20IGNORECASE-Flag%20in%20Regex%20in%20JMP%2C%20aber%20ich%20w%C3%BCrde%20trotzdem%20vorschlagen%2C%20andere%20Methoden%20als%20Regex%20zu%20verwenden%2C%20wenn%20Sie%20nur%20den%20Dateinamen%20(oder%20die%20Erweiterung%20oder%20beides)%20m%C3%B6chten.%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(Quelle%2C%20Muster%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%3EScripting%20Guide%20%26gt%3B%20Datentypen%20%26gt%3B%20Regul%C3%A4re%20Ausdr%C3%BCcke%20%26gt%3B%20Regex-Funktion%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%3EBetreff%3A%20Wie%20kann%20man%20bei%20Regex%20die%20Gro%C3%9F-%2FKleinschreibung%20ignorieren%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-778805%22%20slang%3D%22en-US%22%20mode%3D%22UPDATE%22%3E%3CP%3EDieser%20Hybridcode%20funktioniert%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%3EMein%20bevorzugtes%20JSL%20ist%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%3EBetreff%3A%20Wie%20kann%20man%20bei%20Regex%20die%20Gro%C3%9F-%2FKleinschreibung%20ignorieren%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-779433%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EDanke%2C%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.%20Ich%20wusste%2C%20dass%20ich%20das%20schon%20einmal%20irgendwo%20gesehen%20hatte.%20Nat%C3%BCrlich%20stand%20es%20im%20Skripthandbuch.%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