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