cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
judith
Level I

Which function could quickly remove the blank in front of string?

Which function could I use to remove the blank in front of string? Is there any function that works like left() of SAS? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Which function could quickly remove the blank in front of string?

There doesn't appear to be an LTRIM function.  Here's one way to do it, using a regular expression.

/*

Function Name: ltrim

Description: Trim any spaces on the left side of a string.

Arguments:

in_string   String to do the left trim on

Sample calls:

   a = "   ddd   eee fff   ";

   print(ltrim(a));

   c = "abcde";

   print(ltrim(c));

*/

ltrim = Function( {in_string},

      {Default Local},

// Use the regular expression "^ *" which means start at the beginning of the string

// and match any number of sequential spaces

      start_nonspace = length(Regex(in_string, "^ *"));

      ltrim_string   = substr(in_string, (start_nonspace+1));

      ltrim_string;

);

View solution in original post

5 REPLIES 5
pmroz
Super User

Which function could quickly remove the blank in front of string?

There doesn't appear to be an LTRIM function.  Here's one way to do it, using a regular expression.

/*

Function Name: ltrim

Description: Trim any spaces on the left side of a string.

Arguments:

in_string   String to do the left trim on

Sample calls:

   a = "   ddd   eee fff   ";

   print(ltrim(a));

   c = "abcde";

   print(ltrim(c));

*/

ltrim = Function( {in_string},

      {Default Local},

// Use the regular expression "^ *" which means start at the beginning of the string

// and match any number of sequential spaces

      start_nonspace = length(Regex(in_string, "^ *"));

      ltrim_string   = substr(in_string, (start_nonspace+1));

      ltrim_string;

);

judith
Level I

Which function could quickly remove the blank in front of string?

Thanks a lot for your instruction again. Your answer is always helpful.

ms
Super User (Alumni) ms
Super User (Alumni)

Which function could quickly remove the blank in front of string?

Trim() supports an optional "left", "both" or "right" argument. Default is to trim trailing whitespace at both ends.

s = "   Column Name ";

Trim( s, left );


judith
Level I

Which function could quickly remove the blank in front of string?

That was a quick and simple answer. Thanks for your input.

pmroz
Super User

Which function could quickly remove the blank in front of string?

I should have RTFM'd.  Thanks for pointing that out MS!

Recommended Articles