replace hyphen

pb42pb42 Member Posts: 12 Contributor II
I am trying to replace a hyphen from a Grade attribute by using the Replace operator. I would like to replace it with text that describes no value has been entered (i.e., Not indicated). The problem is that the attribute includes values such as - (the hyphen I want to replace), A-, B-, C-. Using the replace operator replaces all of the hyphens (including those being used as minuses). I tried using the regular expression, \b[-]\b, but that is not working. I also tried, \b["-"]\b without success.
Jasmine_

Best Answer

Answers

  • [Deleted User][Deleted User] Posts: 0 Learner III
    @pb42

    Hello

    This is very similar with your question ;) Take a look on that please :)

    https://community.rapidminer.com/discussion/comment/63840#Comment_63840

    I hope this helps
    mbs
    Jasmine_
  • pb42pb42 Member Posts: 12 Contributor II
    Thank you for the direction. I did read this question, but the solution did not make sense to me.
    Jasmine_
  • varunm1varunm1 Moderator, Member Posts: 1,116   Unicorn
    Hello @pb42

    Can you provide some sample data?
    Regards,
    Varun
    https://www.varunmandalapu.com/

    Be Safe. Follow precautions and Maintain Social Distancing

    Jasmine_
  • pb42pb42 Member Posts: 12 Contributor II
    This is the file
    Jasmine_
  • sgnarkhede2016sgnarkhede2016 Member Posts: 43 Contributor II
    but in replace operator i need to pass "regex" it not working for me 
    e.g
    Sachin N
    Jonn Clara

    I have passed "replace what"  \^(\w+ \w+)
                             "replace by"   \("\w+ \w+")

    I want above string as "Sachin N" and "John Clara"
    Jasmine_
  • Edin_KlapicEdin_Klapic Moderator, Employee, RMResearcher, Member Posts: 281  RM Data Scientist
    If I understood you correctly you want to have the entries in the Attributes completed by leading and trailing double quotes. Value => "Value"
    In this case you replace:
    ^(.+)$
    by
    "$1"
    Happy Mining,
    Edin

    P.S.:
    The Operator Generate Attributes could have also been used. The expression would have been:
    "\"" + AttributeName + "\""
    where AttributeName would be the name of the Attribute which values you want to change.
    Jasmine_[Deleted User]sgenzer
Sign In or Register to comment.