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.  Inconsistent Output from Node

    Employee
    Posted 07-30-2012 14:58

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

    Originally posted by: Cindy

    Hello,

    I have 2 nodes with the same programming that is designed to edit a "comments" field to remove special characters... (The first node contains other editing that seems to be working fine. The second node contains only this programming)

    Comment = if (strFindI('Customer Comments',"'") > -1)
    then replace('Customer Comments',"'","")
    else if (strFindI('Customer Comments',"*") > -1)
    then replace('Customer Comments',"*","")
    else if (strFindI('Customer Comments',"&") > -1)
    then replace('Customer Comments',"&","")
    else if (strFindI('Customer Comments',",") > -1)
    then replace('Customer Comments',",","")
    else 'Customer Comments'
    emit *
    override emit Comment as "Customer Comments"
    ---

    In Node 1, this programming has NO impact on the comments, none of the editing is accomplished. I placed a seperate node with the same programming right after, and it does impact the comments. However, it only removes the & and *, and does not remove the ' or the ,. I don't understand why the programming has no impact in Node 1, and a less than perfect affect in Node 2. Need assistance. Thanks!


  • 2.  RE: Inconsistent Output from Node

    Employee
    Posted 07-30-2012 17:51

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

    Originally posted by: stonysmith

    Because you set it up as an if-then-else chain.. it will only give you one of them.
    You don't need the If/Else stuff...

    Comment = 'Customer Comments'.replace("'","").replace("*","").replace( "&","").replace(",","")
    emit *
    override emit Comment as "Customer Comments"


  • 3.  RE: Inconsistent Output from Node

    Employee
    Posted 08-13-2012 08:43

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

    Originally posted by: ltolleson

    # I HAVE INCLUDED SEVERAL EXAMPLES OF HOW TO REMOVE CHARACTERS FROM A FIELD USING
    # THE FUNCTION regexSubstitute. YOU CAN CHOOSE THE ONE YOU LIKE THE BEST.


    # EXAMPLE 1
    # This was a test to attempt to remove just the special characters.
    # I like the ones below that includes only what you want better than this one.
    # You can keep this as an example of how to exclude certain characters. Any "/" in front
    # of a character escapes that characters so it can be exluded. You have to escape any
    # character that is part of the regular expression language.

    Data_SpecialChar = Data.regexSubstitute("[/&/$/^#()-.!@%/*_/+=~`{}/|:;'/?/</>/[]", "")

    # EXAMPLE 2
    # This example removes any punctuation from the string using something
    # called a "Character Class".

    #Here is a list of Characters Classes that can be used inside a Regular Expression statement

    #Value Meaning
    #----------------------------------------------------------------------------------------------------------
    #[:digit:] Only the digits 0 to 9
    #[:alnum:] Any alphanumeric character 0 to 9 OR A to Z or a to z.
    #[:alpha:] Any alpha character A to Z or a to z.
    #[:blank:] Space and TAB characters only.
    #[:xdigit:] Hexadecimal notation 0-9, A-F, a-f.
    #[:punct:] Punctuation symbols . , " ' ? ! ; : # $ % & ( ) * + - / < > = @ [ ] \ ^ _ { } | ~
    #[:print:] Any printable character.
    #[:space:] Any whitespace characters (space, tab, NL, FF, VT, CR). Many system abbreviate as \s.
    #[:graph:] Exclude whitespace (SPACE, TAB). Many system abbreviate as \W.
    #[:upper:] Any alpha character A to Z.
    #[:lower:] Any alpha character a to z.
    #[:cntrl:] Control Characters NL CR LF TAB VT FF NUL SOH STX EXT EOT ENQ ACK SO SI DLE DC1 DC2 DC3 DC4 NAK SYN ETB CAN EM SUB ESC IS1 IS2 IS3 IS4 DEL.


    Data_Punct = Data.regexSubstitute("[[:punct:]]","")


    # EXAMPLE 3
    # This will remove any character that is not 0-9

    Data_Num = Data.regexSubstitute("[^0-9]", "")

    # EXAMPLE 4
    # This will remove any character that is not 0-9, A-Z, or a-z

    Data_AlphaNum = Data.regexSubstitute("[^0-9A-Za-z]", "")


    emit *, Data_SpecialChar, Data_Num, Data_AlphaNum, Data_Punct