I'm currently trying to make a business card scanner application. The idea here is to photograph the name card and extract the text and classify the text in another EditText.
I have already completed the OCR part, which extracts all text from an image with a name.
Now I am missing the regex method, which can extract all text from OCR and classify the name, email address, phone number into the corresponding fields in EditText.
Through some googling, I already found the regex formulas below:
private static final String EMAIL_PATTERN =
"[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" +
"\\@" +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" +
"(" +
"\\." +
"[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" +
")+";
private static final String PHONE_PATTERN =
"^[89]\\d{7}$";
private static final String NAME_PATTERN =
"/^[a-z ,.'-]+$/i";
I am currently just able to extract the email address using the method below:
public String EmailValidator(String email) {
Pattern pattern = Pattern.compile(EMAIL_PATTERN);
Matcher matcher = pattern.matcher(email);
if (matcher.find()) {
return email.substring(matcher.start(), matcher.end());
} else {
}
return email;
}
, ^ ^, EditText, (, , ).
-------------------------------------------- -------------------------------------------------
@Styx
, "textToUse" , :

. void, . String void, .
