Findpattern Advanced Copy Parsed Test To Field

Issue #858 resolved
Greg Brailsford created an issue

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)

  1. Greg Brailsford reporter

    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.

  2. Fidel Castro Armario repo owner

    Hi @prodriguezbhp,

    There are 2 problems in your expression:

    1. Function findPattern()returns a string list and you should convert it into a string using function toString().
    2. 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.

  3. Greg Brailsford reporter

    Thanks fidel, you have made a great app. I love using it. I love learning a new way to use it.

  4. Log in to comment