I have a document with the following structure:
- A header (some text without any whitespace in the same line)
- A list (could be empty) of values:
- Each value starts with a tab character, and then is text without any whitespaces.
I would like to build a regex pattern such that each match contains 1 header group and 0-n values group.
Here is what I am trying, which I believe it is quite close, but probably some small problem I can't find:
https://regex101.com/r/XSszya/1
^(?P<header>[^\s] )$(?P<value>^\t[^\s]$)*
Thanks.
CodePudding user response:
You can repeat the second part starting with a newline and a tab.
Then repeat the inner part of the value
group in its own non capture group to get the whole match in group value
^(?P<header>\S )(?P<value>(?:\n\t\S )*$)