Why is this code only spitting out the entire regex match instead of the capture group?
Input
@\"A long string containing Name:>
In swift3
//: Playground - noun: a place where people can play
import UIKit
/// Two groups. 1: [A-Z]+, 2: [0-9]+
var pattern = "([A-Z]+)([0-9]+)"
let regex = try NSRegularExpression(pattern: pattern, options:[.caseInsensitive])
let str = "AA01B2C3DD4"
let strLen = str.characters.count
let results = regex.matches(in: str, options: [], range: NSMakeRange(0, strLen))
let nsStr = str as NSString
for a in results {
let c = a.numberOfRanges
print(c)
let m0 = a.rangeAt(0) //< Ex: 'AA01'
let m1 = a.rangeAt(1) //< Group 1: Alpha chars, ex: 'AA'
let m2 = a.rangeAt(2) //< Group 2: Digital numbers, ex: '01'
// let m3 = a.rangeAt(3) //< Runtime exceptions
let s = nsStr.substring(with: m2)
print(s)
}