我正在使用Swift 3并尝试访问捕获的组.
let regexp = "((ALREADY PAID | NOT ALR | PROVIDER MAY | READY | MAY BILL | BILL YOU | PAID)((.|\\n)*))(( \\d+)(\\.+|-+)(\\d\\d))"
// check if some substring is in the recognized text
if let range = stringText.range(of:regexp, options: .regularExpression) {
let result = tesseract.recognizedText.substring(with:range)
}
Run Code Online (Sandbox Code Playgroud)
我希望能够提取出捕获的最后两个数字(\d\d),所以如果文本是:ALREADY PAID asfasdfadsfasdf 39.15,它将提取15.这是一个正则表达式构建器,显示我想要的内容.通常情况下,我可以做到$8第8组被提取,但我不知道如何在Swift 3中做到这一点.