I have a specification of the command
RENAME_SECTION file::section [new_file::]new_section
file, section and new_section are mandatory, new_file is optional.
Than means that all next expressions will match:
RENAME_SECTION io.cfg::BUS1 io.cfg::BUS3
RENAME_SECTION io.cfg::BUS2 io_new.cfg::BUS2
RENAME_SECTION io.cfg::VID VID1
I try to get all provided parameters with Python re.search(pattern, config_line) using the pattern
(?P<command>RENAME_SECTION\s)\s*(?P<file>\S+)::(?P<section>.*)\s+(?P<target_file>\S*)[::]?(?P<target_section>.*)
This pattern match two first cases, but not the third one, the reason is absents of last ::.
How can I bundle :: with target_file named capture group?