捕获数据并将其传递到文本字段

Capture and pass data into textfields

我目前正在开发光学字符识别 (OCR) 应用程序,它将识别的数据从名片传递到 contact.I 已经设法从名片 recognized the data

问题是如何识别该文本框中的phone数字等内容并将其传递到phone contact textfield?

你可以试试这个:

String text  = "This is the text 2432423 which contains phone numbers 56565555";

Pattern pattern = Pattern.compile("\d{5,12}"); // at least 5 at most 12
// before match remove all the spaces, to ensure the length on numbers is OK it will work more better. 
Matcher matcher = pattern.matcher(text.replaceAll(" ", ""));
while (matcher.find()) {
    String num = matcher.group();
    System.out.println("phone = " + num);
}

这是输出:

phone = 2432423
phone = 56565555

注意:最少和最多,你可以根据自己的需要更改。