im using swift 4 and got some problems with regex captured group.
so , i have regex here :
let regex = try! NSRegularExpression(pattern:"Tambah saldo via (merchant|transfer (online|bank)).(\\w+ \\.?)($)?(((\\w+\\.)?\\w+? (\\w+ )?\\.) No Rek:([0-9]+(.[0-9])*).[^0-9]+([0-9]+))?", options: .caseInsensitive)
and has multiple response :
let response1 = "Tambah saldo via transfer bank BCA PT.BARRYPRIMA CORP . No Rek:427.123.444 . Jumlah transfer Rp.200864."
let response2 = "Tambah saldo via transfer online Bersama BARRYPRIMA CORP . No Rek:123456. Jumlah transfer Rp.200864."
let response3 = "Tambah saldo via transfer bank Mandiri BARRYPRIMA . No Rek:43512343598347. Jumlah transfer Rp.200864."
let response4 = "Tambah saldo via merchant Tito ."
let response5 = "Tambah saldo via merchant Bagaskara putra."
i want to get multiple values and store it to [String] the value im looking is
1: "transfer bank" , "BCA" , "PT.BARRYPRIMA CORP","427.123.444","200864"
2: "transfer online", "Bersama", "BARRYPRIMA CORP", "123456","200864"
3: "transfer bank" , "Mandiri" , "BARRYPRIMA","43512343598347","200864"
4: "merchant","tito"
5: "merchant","bagaskara putra"
i ve tried function from this one
and get this errors
Thread 1: Fatal error: subscript: subrange extends past String end