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.  Find text and replace all text to that point

    Employee
    Posted 07-20-2014 22:59

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

    Originally posted by: dglavastorm

    Hi, I need a way to remove all text up to the word "NOTES", leaving all text following that in tact. "NOTES" can appear anywhere in the text but is system generated so always present.

    Examples below with header "NOTES" and three fields-

    NOTES
    requestId:n_20140211|ACBID:471153333|NOTES:xxxxxy
    requestId:n_20140210|CPN:0418335555|ACBID:46994952 |NOTES:Agent Callback about 0418337820 INFO - xxxxxxxxxxxyyyyyyyyy
    requestId:n_20140215|FNN:0418775555|ACBID:46994952 |GNN: NO|NOTES:Agent Callback about 0418337820 INFO - xxxxxxxxxxxyyyyyyyyy


    So end result is
    NOTES
    NOTES:xxxxxy
    NOTES:Agent Callback about 0418337820 INFO - xxxxxxxxxxxyyyyyyyyy
    NOTES:Agent Callback about 0418337820 INFO - xxxxxxxxxxxyyyyyyyyyzzzzzzz zzzz zzzzz


    I've tried the "Replace Text" node and using a Filter node with regexSubtitute and can make it remove set text, but I can't find any help on how to find text in a string and delete all before it.

    eg. - New = CTIDATA_AACB.regexSubstituteI("NOTES","")


    Desperate Thanks,

    Dave


  • 2.  RE: Find text and replace all text to that point

    Employee
    Posted 07-21-2014 00:01

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

    Originally posted by: Tim Meagher

    Hi,

    I think the following is what you will need to do in a filter node:

    notesIdx = 'CTIDATA_AACB'.strFind("NOTES")
    new = 'CTIDATA_AACB'
    if (notesIdx != -1) then {
        new = 'CTIDATA_AACB'.substr(notesIdx)
    }
    emit new as "CTIDATA_AACB"
    The first line just tries to locate where the string "NOTES" starts in the input field.
    Then, if this exists (the index is not equal to -1), a substring of the original field is taken, starting at the index where "NOTES" was found.
    This new value is then emitted.

    Bear in mind that if there is no "NOTES" text in the input string, this will output the original string without any modifications.
    Also, this only finds the string "NOTES", not "notes" or "Notes" etc - i.e. it is case-sensitive.
    To find "NOTES" case-insensitively, use the strFindI operator instead of strFind.

    Hope this helps,
    Tim.


  • 3.  RE: Find text and replace all text to that point

    Employee
    Posted 07-21-2014 00:18

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

    Originally posted by: dglavastorm

    Works perfectly, huge thanks :-).