Force parsing optional groups
问题 I'm trying to make a regex string that extracts data from report files. The tricky part is that I need this single regex string to match multiple report file content formats. I want the regex to always match even if some optional groups are not found. Take the following report files content ( Note : #2 is missing the "val2" part.): File #1: " -val1-test-val2-result-val3-done- " Expected Result: Val1 Group: test Val2 Group: result Val3 Group: done File #2: " -val1-test-val3-done- " Expected