I have a list of strings for example:
("2019_FOO_BAR.1_12"
"2019_FOO_BAR.1_13"
"2018_FOO_BAR.1_12"
"2019_FOO_XYZ.1_14"
"2017_FOO_BAR.1_14"
"2017_FOO_XYZ.1_12"
"2019_FOO_XYZ.1_13")
I want to group them by common substring after first underscore and before the dot.
In this example I have 2 unique substrings FOO_BAR and FOO_XYZ. But longer list may have N unique substrings.
I want the result to look like this:
(["2019_FOO_BAR.1_12" "2019_FOO_BAR.1_13" "2018_FOO_BAR.1_12" "2017_FOO_BAR.1_14"]
["2017_FOO_XYZ.1_12" "2019_FOO_XYZ.1_13" "2019_FOO_XYZ.1_14"])
So each substring is grouped in a separate list