With Python I need to parse the following string, that can be written in four different ways:
:param MyParam: My description [MyValue] {MyGroup}
:param MyParam: My description [MyValue]
:param MyParam: My description {MyGroup}
:param MyParam: My description
The expectation is to extract MyParam, My description, MyValue and MyGroup
I tried with the following pattern:
^\:param(?P<param>.*)\:(?P<desc>.*)\s*(\[(?P<value>.*)\])?\s*(\{(?P<group>.*)\})?$
but in all cases it is too greedy.
Using the following one:
^\:param(?P<param>.*)\:(?P<desc>.*) (\[(?P<value>.*)\])? (\{(?P<group>.*)\})?$
I get valid results only if there are spaces according to the pattern expectations.
Any idea how to fix this ?
.*?instead of.*.