Skip to content

Email address regular expression as close as possible to the specification in RFC 6531.

License

Notifications You must be signed in to change notification settings

MichaelDark/rfc_6531

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

⚠️ Found a bug?

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.

Validating email

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'));
}

Named Capture Groups

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));
}

Support

Buy Me A Coffee

About

Email address regular expression as close as possible to the specification in RFC 6531.

Topics

Resources

License

Stars

Watchers

Forks

Languages