Due to recent updates, all users are required to create an Altair One account to login to the RapidMiner community. Click the Register button to create your account using the same email that you have previously used to login to the RapidMiner community. This will ensure that any previously created content will be synced to your Altair One account. Once you login, you will be asked to provide a username that identifies you to other Community users. Email us at Community with questions.

How to remove characters from end of string using regular expression within Replace operator?

User118722User118722 Member Posts: 3 Contributor I
Hi, 

I'm trying to remove certain characters from the end of string in a text field using Replace operator, for example, 

Current value: abcd(xxx)
Desired value: abcd

In the replace operator, I use the following regular expression to locate strings end with (xxx), but what should I put in as Replacement? 
(.*)(?:abc)(.*)

Thank you! 


Tagged:

Answers

  • kaymankayman Member Posts: 662 Unicorn
    ^(abcd).*$ and replace with $1
    Read as start from the beginning (^) , grab what you need, ignore everything else till the end ($) 
  • User118722User118722 Member Posts: 3 Contributor I
    This solution did not work for me. And sorry I wasn't clear on my example. Current value is a not a fixed string - it may contain all kinds of combinations with characters, space and/or symbols, the characters I would like to get rid of is a fixed set of characters within in parenthesis, which always show up at the end of current value. My desired value would be the current value excluding the parenthesis and the content in it. 
  • kaymankayman Member Posts: 662 Unicorn
    So like your original regex then? You just need to replace with $1$2 then, this would strip your ABC.

    But your example is very confusing so I may misunderstand you. Do you have a more real live example? 
Sign In or Register to comment.