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.
You could use 2 capture groups and you could get the matches using $1
and $2
:
(\w+)\|([a-f0-9]+(?:-[a-f0-9]+)+)\b
(\w+)
Capture group 1, match 1+ word chars\|
Match |
(
Capture group 2
[a-f0-9]+
Match 1+ chars a-f 0-9(?:-[a-f0-9]+)+
Repeat 1+ times matching -
and 1+ chars a-f o-9)\b
Close group 2 followed by a word boundary to prevent a partial matchSee 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