cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.
  • See how to access JMP Marketplace - and - find, create & share add-ins to extend your JMP. Watch video.

Discussions

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

Substituting a space for underscore in a character string

Hi:

I have a long description of a product that includes a bunch of underscores __ which I don't want. I'd like to replace them with spaces instead. 

I've tried using substr(substitute(columnname, "_",""),1, 999) but that just makes the entire field blank. 
I've also tried the reverse (substitute(substr....) same problem.

 

Help!

JMP 17 FWIW. 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Substituting a space for underscore in a character string

Just using Substitute should be enough (or Substitute Into() depending on what you are doing)

Names Default To Here(1);

str = "aaa________b_c_________________d";
new_str = Substitute(str, "_", " "); // "aaa        b c                 d"

 

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Substituting a space for underscore in a character string

Just using Substitute should be enough (or Substitute Into() depending on what you are doing)

Names Default To Here(1);

str = "aaa________b_c_________________d";
new_str = Substitute(str, "_", " "); // "aaa        b c                 d"

 

-Jarmo

Re: Substituting a space for underscore in a character string

Hi, notice that Jarmo's code replaces the underscores with a space character, " ", while your code replaced the underscores with the empty string, "", which was at least part of the problem.

 

Recommended Articles