regexnintex-workflow

Regex to get text before pipe in Germany|fbf4cf3c-ebfe-43c8-aaf9-6811bd3488b0


I have a text given in this format

Germany|fbf4cf3c-ebfe-43c8-aaf9-6811bd3488b0

How does the Regex have to look like to get Germany and how does the Regex have to look like to get fbf4cf3c-ebfe-43c8-aaf9-6811bd3488b0?

I use Nintex Workflow and tried .+?(?=\|), but it's not working properly.


Solution

  • You could use 2 capture groups and you could get the matches using $1 and $2:

    (\w+)\|([a-f0-9]+(?:-[a-f0-9]+)+)\b
    

    See a regex demo

    To get the separate matches, you might also use lookarounds.

    Match 1 or more word charactes asserting a | and guild like format to the right using a positive lookahead:

    \w+(?=\|[a-f0-9]+(?:-[a-f0-9]+)+\b)
    

    Or match a guild like pattern asserting a word char followed by a | to the left using a positive lookbehind:

    (?<=\w\|)[a-f0-9]+(?:-[a-f0-9]+)+\b