Findpattern Advanced Copy Parsed Test To Field
I have a multi select field with names and email addresses. On a post function I am trying to copy only the email addresses and paste them in email address custom text field.
I am using copy parsed text to field. in advanced mode with the following: findPattern(%{21748}, "\S+@\S+|{(?:\w+, *)+\w+\}@\w.-+")
When I try the above I get the following error: The following text parsed in advanced mode will be copied to ClientEmail: findPattern(%{21748}, "\S+@\S+|{(?:\w+, *)+\w+\}@\w.-+") >>> PARSE ERROR: Encountered " "findPattern" "findPattern "" at line 1, column 1. Was expecting one of: "-" ... <NUMBER> ... "(" ... "round" ... "floor" ... "ceil" ... "abs" ... "remainder" ... "sqrt" ... "cbrt" ... "random" ... "pow" ... "max" ... "min" ... "modulus" ... "log10" ... "log" ... "sin" ... "cos" ... "tan" ... "asin" ... "acos" ... "atan" ... "sinh" ... "cosh" ... "tanh" ... "toDegrees" ... "toRadians" ... "numberOfSelectedItems" ... "numberOfAvailableItems" ... "length" ... <NUM_DAT_CF> ... <STRING_CF> ... <CASCADING_CF> ... <REMOTE_NUMERIC_VALUE> ... <REMOTE_STRING_VALUE> ... "previousValue" ... "second" ... "minute" ... "hour" ... "dayOfTheWeek" ... "dayOfTheMonth" ... "month" ... "year" ... "timePart" ... "datePart" ... "addDaysSkippingWeekends" ... "addTimeSkippingWeekends" ... "subtractDates... This feature will be run as user in field Current user. by JWT
Should I be using find pattern? or is there another regex tool that would be better. Here is the data in the multislect list: greg brailsford | greg.brailsford@test.com, Debbie Kelly | dkelly@test.com, Jason Brown | jbrown@test.com, Brian King| bking@test.com
This is what I want pasted in the new field: greg.brailsford@test.com, Dkelly@test.com, jborwn@test.com, bking@test.com
I was successful with replaceAll and a different regex but it did not work well once I had more than two contacts selected.
Thanks.
Comments (4)
-
reporter -
repo owner Hi @prodriguezbhp,
There are 2 problems in your expression:
- Function
findPattern()
returns a string list and you should convert it into a string using functiontoString()
. - You should escape character
\
in your string literal representing the regular expression.
Try the following string expression:
toString(findPattern(%{00000}, "\\S+@\\S+|{(?:\\w+, *)+\\w+\\}@\\w.-+"))
A simpler solution is to use "Parse field for extracting data" post-function, which has a specific functionality for extracting email addresses.
- Function
-
reporter Thanks fidel, you have made a great app. I love using it. I love learning a new way to use it.
-
repo owner - changed status to resolved
Thanks for your kind words, Greg!
- Log in to comment
I went back to replaceAll and changed my regex to select everything that is not an email address. I replaced that with nothing. replaceAll(%{21748}, "(^|\s)[^@]+($|\s)", "")
This is working for me but not sure if you still need to look into the above error or not.