Using the replace operator to convert lowercase to uppercase

christina5
christina5 New Altair Community Member
edited November 5 in Community Q&A

Hello, I am trying to use the replace operator to replace all lowercase letters in the values belonging to an attribute, with their uppercase counterparts. My "replace what" regex expression is working (it is [a-z] ), but my "replace by" expression ( [A-Z] ) simply replaces every lowercase character with "[A-Z]", not the uppercase version of the character it is supposed to replace. What is the correct regex expression for the replace by parameter to replace the characters with their uppercase versions?

Thanks!

 

Tagged:

Best Answer

  • kayman
    kayman New Altair Community Member
    Answer ✓

    Not sure if I understood the problem correctly, but if you simply want to uppercase all values for a given attribute the easiest way is to generate a new attribute, give it the same name and replace it with upper([name_of_attribute]).

     

    As far as I know this cannot really be done with regex in RM.

Answers

  • christina5
    christina5 New Altair Community Member

    Thanks, but I am surprised that I need to write a groovy script to do this very simple task - I saw another thread that said it can be done with a replace and regular expressions.

    I am trying to do a global search and replace letters in the values that belong to an attribute from lowercase to uppercase, not the attribute itself.  I think I could just do it easier in pandas rather than learn groovy.

    It seems like a straightforward thing to want to do, as the join operator is case sensitive.

     

  • kayman
    kayman New Altair Community Member
    Answer ✓

    Not sure if I understood the problem correctly, but if you simply want to uppercase all values for a given attribute the easiest way is to generate a new attribute, give it the same name and replace it with upper([name_of_attribute]).

     

    As far as I know this cannot really be done with regex in RM.

  • christina5
    christina5 New Altair Community Member

    Thanks so much, this worked like a charm!  Exactly what I wanted to do.

     

  • sgenzer
    sgenzer
    Altair Employee

    hello @christina5 - another approach for future knowledge is to use the Text Processing extension and use the "Transform Cases" operator.

     

    Scott

     

  • robin
    robin New Altair Community Member

    Transform cases is not very friendly, requires a to run through Process From Data operator to convert to doc and then back again.