Using the replace operator to convert lowercase to uppercase

christina5christina5 Member Posts: 3 Contributor I
edited December 2018 in Help

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?



Best Answer

  • Options
    kaymankayman Member Posts: 662 Unicorn
    Solution Accepted

    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.


  • Options
    Thomas_OttThomas_Ott RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,761 Unicorn
  • Options
    christina5christina5 Member Posts: 3 Contributor I

    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.


  • Options
    christina5christina5 Member Posts: 3 Contributor I

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


  • Options
    sgenzersgenzer Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959 Community Manager

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




  • Options
    robinrobin Member Posts: 100 Guru

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

Sign In or Register to comment.