extractEmails static method

List<String> extractEmails(
  1. String text
)

Extract email addresses from string

text - The text to extract emails from Returns list of email addresses found

Implementation

static List<String> extractEmails(String text) {
  final regex = RegExp(r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b');
  return regex.allMatches(text).map((match) => match.group(0)!).toList();
}