Skip to content

Instantly share code, notes, and snippets.

@bluepnume
Last active August 7, 2020 18:05
Show Gist options
  • Save bluepnume/e3caec919e31ecd896af2b5a26f5cb18 to your computer and use it in GitHub Desktop.
Save bluepnume/e3caec919e31ecd896af2b5a26f5cb18 to your computer and use it in GitHub Desktop.
/* @jsx regex.node */
import { regex, Regex, RegexGroup as Group, RegexText as Text, RegexWord as Word } from 'jsx-pragmatic';
const email = '[email protected]';
const match = email.match(
<Regex>
<Word />
<Group optional>
<Text>.</Text>
<Word />
</Group>
<Text>@</Text>
<Group union name='provider'>
<Text>paypal</Text>
<Text>google</Text>
<Text>$mail</Text>
</Group>
<Text>.</Text>
<Group union name='tld'>
<Text>com</Text>
<Text>org</Text>
<Text>net</Text>
</Group>
</Regex>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment