Skip to content

Instantly share code, notes, and snippets.

@mtrencseni
Last active March 2, 2019 15:55
Show Gist options
  • Save mtrencseni/a2ed2d2b63325687afa1b31ee3c1136a to your computer and use it in GitHub Desktop.
Save mtrencseni/a2ed2d2b63325687afa1b31ee3c1136a to your computer and use it in GitHub Desktop.
# regex pattern: [\w.%+-]+@[\w.-]+\.[a-zA-Z]{2,6}
# equivalent rxe code:
username = rxe.one_or_more(rxe.set([rxe.alphanumeric(), '.', '%', '+', '-']))
domain = (rxe
.one_or_more(rxe.set([rxe.alphanumeric(), '.', '-']))
.literal('.')
.at_least_at_most(2, 6, rxe.set([rxe.range('a', 'z'), rxe.range('A', 'Z')]))
)
email = (rxe
.exactly(1, username)
.literal('@')
.exactly(1, domain)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment