Skip to content

Instantly share code, notes, and snippets.

@programmerbrown
Last active November 26, 2017 22:09
Show Gist options
  • Save programmerbrown/642de2e35b3899331472f0f55786547b to your computer and use it in GitHub Desktop.
Save programmerbrown/642de2e35b3899331472f0f55786547b to your computer and use it in GitHub Desktop.
Regular Expressions

Verify Username

Description

This regular expression matches an username with the following conditions:

  • it is between 8 to 30 characters
  • it contains only a through z, A through Z, 0 through 9, and underscore
  • it begins with an alphabetic character

Regular Expression:

/^[a-zA-Z](?!.*[?@!]).{7,29}$/igm

Link to RegExr.com example

Duplicate Words

Description

This regular expression matches duplicate words is not case-sensitive.

Regular Expression:

/\b([a-z]+)\b(\s\1\b)+/igm

Link to RegExr.com example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment