how to add quotes each word in string(these are my attributes name)

sgnarkhede2016
sgnarkhede2016 New Altair Community Member
edited November 5 in Community Q&A
how to add quotes each word in string(these are my attributes name)

e.g.
query=Sachin,Amit,Clara,Josef'

it should be converted into
query='Sachin','Amit','Clara','Josef'

Best Answer

  • kayman
    kayman New Altair Community Member
    Answer ✓
    \^ escapes your special symbol, so instead of starting at the beginning of your attribute (what would happen with ^) your expression is now looking for the character ^ instead.

    You will also only find matches that are word + word, so if your attribute is existing of a single word it will fail also.

    What would probably work better is something like this : 

    ^(.*)$ which means just select my whole attribute value from beginning to end, and replace with "$1" , so quot + stored result + quote


Answers

  • [Deleted User]
    [Deleted User] New Altair Community Member
    edited March 2020
    @sgnarkhede2016

    Hello 

    I think you can use Replace operator  :). Read the document please and take a look at other link ;)
    https://docs.rapidminer.com/latest/studio/operators/blending/values/replace.html

    https://community.rapidminer.com/discussion/comment/63890#Comment_63890

    I hope this helps
    mbs
  • sgnarkhede2016
    sgnarkhede2016 New Altair Community Member
    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"
  • kayman
    kayman New Altair Community Member
    Answer ✓
    \^ escapes your special symbol, so instead of starting at the beginning of your attribute (what would happen with ^) your expression is now looking for the character ^ instead.

    You will also only find matches that are word + word, so if your attribute is existing of a single word it will fail also.

    What would probably work better is something like this : 

    ^(.*)$ which means just select my whole attribute value from beginning to end, and replace with "$1" , so quot + stored result + quote