Subscribe Bookmark RSS Feed

Regex function to create new column

cloudvirake

Community Member

Joined:

Sep 4, 2017

 

QuestionIDQuestionCAT
CR067Q01TCR
S067Q01TS

 

I am trying to create a new column with the following formula in the "QuestionCAT" column:

Regex (QuestionID, "[a-zA-Z]*")

However, the formula does not seem to work for JMP Pro Version 13.0. Does anyone know what is the issue?

1 REPLY
Craige_Hales

Staff

Joined:

Mar 21, 2013

In your example, CR067Q01T matched the CR and stopped at the zero. What do you need it to match? If you need to remove all the digits, something like this might work:

regex("CR067Q01T", "\d+", "", GLOBALREPLACE)

"CRQT"

blog post on regex

 

update: also, you might want +, rather than *, for the repetition. * means zero or more and + means one or more. [A-Z]* will match zero letters at the beginning of "123ABC", which might not be what you want. [A-Z]+ will advance past the digits in order to get at least one letter, then get all three.

Craige