LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  How to replace Specific set of data from a column after finding a word in it

    Employee
    Posted 08-02-2016 08:36

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Jagdev

    Hi Experts,

    I need your assistance to remove the following data from a column.

    • I want the remove the bracket and the data within it if it appears anywhere with the data ex – ABD (Rear) and DEF (Rear Sample). The answer should be ABD and DEF
    • I want to remove a data which appears before a specific word. Like search for a word "Block" in a line “Sample 1/3, Floor U/G, Block extra” and remove everything exclude word "extra" or say I have a list of words and if any of this word appears in a column then rest of the data should be deleted and the word should appear in its place.

    Regards,
    Jagdev


  • 2.  RE: How to replace Specific set of data from a column after finding a word in it

    Employee
    Posted 08-03-2016 05:10

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Jagdev

    Hi Experts,

    Any views on the above query.

    Regards,
    Jagdev


  • 3.  RE: How to replace Specific set of data from a column after finding a word in it

    Employee
    Posted 08-03-2016 14:58

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: prasmussen

    Here you go:

    1st Bullet
    text="ABD (Rear) and DEF (Rear Sample)"
    nText=text
    while nText.strFindI("(") > -1
    {
    fParenthesis=nText.strFind("(")
    sParenthesis=nText.strFind(")")
    offset=sParenthesis - fParenthesis
    vText=nText.substr(fParenthesis-1,offset+2)
    nText=nText.replace(vText,"").trim()
    }
    emit text,nText

    2nd Bullet
    text="Sample 1/3, Floor U/G, Block extra"
    searchString="Block"
    foundString = text.strFindI(searchString)
    if foundString > -1 then nText=text.replace(text.substr(foundString,text.st rlen()),searchString)
    emit text, nText


    On the 2nd bullet, you could put the search string in a list and loop through it as well for a list of words:
    i=0
    text="Sample 1/3, Floor U/G, Block extra"
    searchList=list("Block","AnyValue")

    while i < searchList.len() {
    foundString = text.strFindI(searchList[i])
    if foundString > -1 then nText=text.replace(text.substr(foundString,text.st rlen()),searchList[i])
    i=i+1
    }
    emit text, nText


  • 4.  RE: How to replace Specific set of data from a column after finding a word in it

    Employee
    Posted 08-09-2016 22:56

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Jagdev

    Hi Prasmussen,

    Thanks for your input on the above thread. I will implement the code in my live examples and will get back in case of any clarification.

    Regards,
    Jagdev