[core][build] selected groups rework (allow selection from the pattern end)