Skip to main content

Regex in handlebar to get everything after the first whitespace doesn't work during flow execution

Comments

5 comments

  • Kate Larson Senior UX Researcher Community moderator

    Hi Ugene Jude -

    I created a Support ticket for this issue. You should receive an email with the information.

    Thanks!

    Kate

    0
  • Ugene Jude Channel Partner
    Engaged
    Celigo University Level 4: Legendary

    Thank you Kate

    0
  • Merik Ducker
    Awesome Follow-up
    Celigo University Level 4: Legendary
    Engaged

    Hi Ugene -

    I hope you're doing well.

    Did you happen to come across a solution to this one?

    - Merik

    0
  • Merik Ducker
    Awesome Follow-up
    Celigo University Level 4: Legendary
    Engaged

    Here's where I landed:

    {{#compare (regexSearch VendorName " ") ">" -1}}{{trim (substring VendorName (regexSearch VendorName " "))}}{{else}}.{{/compare}}

    Explanation:

    (regexSearch VendorName " ")
    • returns zero-indexed position of first space
    • returns -1 when string does not contain space
    (substring VendorName (regexSearch VendorName " "))
    • returns substring starting with (inclusive) first space
    • it should be noted that I've already trimmed my VendorName on earlier export
    • there would be issues if VendorName had leading spaces
    • namely, this output intended to be Last Name would be equivalent to First Name
    {{trim (substring VendorName (regexSearch VendorName " "))}}
    • removes whitespace present at start or end of substring 
    {{else}}.{{/compare}}
    •  returns period in scenario where string does not contain a space
    1
  • Jake Naydock
    Great Answer

    Merik Ducker Thank you for this workaround and explanation!! I ran into the same issue, and was able to get around it with your method. You just saved me a ton of time.

    For anyone else wondering, the reason that this error occurs is because Javascript does not support lookahead / lookbehind, and "?" is involved in the process. You will need to find a different way to structure your formula that avoids lookaheads/lookbehinds.

    0

Please sign in to leave a comment.