RFC 6531 Email address regular expression.
Email address regular expression as close as possible to the specification in RFC 6531.
For more information on current limitations and detailed overview of used Named Capture Groups refer to the original GitHub Gist.
If you find a bug, please submit a PR containing a fix or file an issue with the problematic email and justification for why it should be compliant or non-compliant.
import 'package:rfc_6531/rfc_6531.dart' as rfc_6531;
void main() {
print(rfc_6531.regExp.hasMatch('user@example.com'));
print(rfc_6531.regExp.hasMatch('not-an-email'));
}
Used Named Capture Groups used are accessible via Groups
class, with their names being accesing via GroupNames
.
import 'package:rfc_6531/rfc_6531.dart' as rfc_6531;
void main() {
final match = rfc_6531.regExp.allMatches('user@example.com').first;
print(match.namedGroup(rfc_6531.GroupNames.localPart));
print(match.namedGroup(rfc_6531.GroupNames.domain));
}