Subscribe Bookmark RSS Feed

script to insert whitespace before capital letters for all columns

mt

New Contributor

Joined:

Jun 7, 2017

Hi guys. I'm getting started on jmp scripting (just got a basic handle on for-loops), but I'm a bit stuck on the JMP syntax still.

 

I want to write an automated script that find capital letters across all columns in the active data table, and adds a whitespace character before the capital letters. so "TimeSpent" --> " Time Spent". I'd then use a trim function to remove the initial whitespace before the "T". 

 

Thanks heaps!

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

Regex is particularly good at this:

value = "TimeSpentOnMyProject";
newvalue = regex( value, "([a-z])([A-Z])", "\1 \2", GLOBALREPLACE);
show(value,newvalue);

value = "TimeSpentOnMyProject";
newvalue = "Time Spent On My Project";

 

post here

Craige
2 REPLIES
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution

Regex is particularly good at this:

value = "TimeSpentOnMyProject";
newvalue = regex( value, "([a-z])([A-Z])", "\1 \2", GLOBALREPLACE);
show(value,newvalue);

value = "TimeSpentOnMyProject";
newvalue = "Time Spent On My Project";

 

post here

Craige
mt

New Contributor

Joined:

Jun 7, 2017

Thank you, it works!