flatten links array as scan with regex groups returns nested array