It can be implemented with a formula or a regex
I only know how to use this formula, but it's definitely not right.I don't want to do it in a circular way.
Length(txt)-Length(Substitute(txt, " ", ""))
Thanks!
Scripting Guide Introduction to Writing JSL Scripts What JSL Can Do for You Help with Learning JSL The Scripting Index Let JMP Teach You JSL JSL Terminology Basic JSL Syntax Scripting Guide Conventions Get Started Capture a Script for an Analysis Report Capture a Script for a Data Table Capture a Script to Import a File Glue Scripts Together
This is similar to your code, but I would suspect it will more correct, because your code will substitute the blank characters within the text.
txt = " Scripting Guide"; numLeadingBlanks = Length( txt ) - Length( Trim( txt ) );
It can also return an error if there are trailing blanks.
This should correct for that issue
txt = " Scripting Guide "; numLeadingBlanks = Contains( txt, Substr( Trim( txt ), 1, 1 ) ) - 1;
You can also provide Trim() with optional argument left (it defaults to both) so it trims only start of the string
txt = " Scripting Guide "; numLeadingBlanks = Length(txt) - Length(Trim Whitespace(txt, left));
(Trim Whitespace() should just be an alias for same function but it is more clear so I tend to use it)