Does Rapidminer support 'RSPLIT'?

ChaewonChaewon MemberPosts:2Newbie
Does Rapidminer support 'RSPLIT'? I mean split delimited text from right side.
For example,
string = "tic-tac-toe"
print(string.rsplit('-', 1))
['tic-tac', 'toe']

Best Answer

  • ChaewonChaewon MemberPosts:2Newbie
    Solution Accepted
    Thank you so much for your answer. Balazs. It works perfectly.
    Happy new year.

Answers

  • BalazsBaranyBalazsBarany Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified ExpertPosts:941Unicorn
    Hi!

    You can achieve this easily with a regular expression replacement.

    In Generate Attributes, you can use such a function:
    replaceAll(string, "(.+)-(.+)", "$1")
    $1 refers to the first match, $2 to the second one. Regular expression matches are "greedy", so the first one consumes as much of the string as it can, until the dash, and puts the rest into the second match.

    Here's an example process:
                                                 


    Regards,
    Balázs


Sign InorRegisterto comment.