Skip to content

Instantly share code, notes, and snippets.

@clm-a
Created April 5, 2011 10:39
Show Gist options
  • Save clm-a/903410 to your computer and use it in GitHub Desktop.
Save clm-a/903410 to your computer and use it in GitHub Desktop.
A regexp not to match a whole word.
# following DOES match "foobar", "fooadmin", "adminbar", "fooadminbar" but not "admin" as a whole word :
/^((?!\badmin\b)[^\s]*)$/
# more reserved keywords :
/^((?!\badmin\b|\bteam\b)[^\s]*)$/
# http://www.regular-expressions.info/wordboundaries.html
# http://www.regular-expressions.info/lookaround.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment