Skip to content

Instantly share code, notes, and snippets.

@DaemonLoki
Last active February 9, 2019 12:46
Show Gist options
  • Save DaemonLoki/3445f7902a405e6873a7dd8d30509f1e to your computer and use it in GitHub Desktop.
Save DaemonLoki/3445f7902a405e6873a7dd8d30509f1e to your computer and use it in GitHub Desktop.
String mailPattern = r"^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$";
RegExp regEx = RegExp(mailPattern);
String mailAddress = "Couldn't find any mail in the foto! Please try again!";
for (TextBlock block in visionText.blocks) {
for (TextLine line in block.lines) {
if (regEx.hasMatch(line.text)) {
mailAddress = line.text;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment