Skip to main content

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

Comments

4 comments

  • Kate Larson Community moderator Principal Technical Writer
    Celigo University Level 3: Master

    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
    0

Please sign in to leave a comment.