I think an image a better than words sometimes.
My problem as you can see, is that It only matches two words by two. How can I match all of the words ?
My current regex (PCRE) : ([^\|\(\)\|] )\|([^\|\(\)\|] )
The goal : retrieve all the words in a separate groupe for each of them
CodePudding user response:
You can use an infinite length lookbehind in C# (with a lookahead):
(?<=\([^()]*)\w (?=[^()]*\))
To match any kind of strings inside parentheses, that do not consist of (
, )
and |
, you will need to replace \w
with [^()|]
:
(?<=\([^()]*)[^()|] (?=[^()]*\))
// ^^^^^^