Regular Expressions 101

Community Library

Community Library Entry

0

Regular ExpressionOpen Workspace

/
\b (?!\p{Lu}+\b) # CaMeL can't be an ALLCAPS (remove to allow) (?=\p{L}*\p{Ll}) # CaMeL word should have at least 1 lowercase letter (?=\p{L}*\p{Lu}) # CaMeL word should have at least 1 uppercase letter (?!\p{Lu}\p{Ll}*\b) # CaMeL word can't be `Xxxx` or `X` \p{L}+ # CaMeL word should contain at least 1 letter \b
/
gx

Description
Created·2016-06-13 08:01
Type·Match
Flavor·PCRE (Legacy)

The PCRE (or any regex flavor supporting word boundaries, Unicode properties and lookaheads) \b(?!\p{Lu}+\b)(?=\p{L}\p{Ll})(?=\p{L}\p{Lu})(?!\p{Lu}\p{Ll}*\b)\p{L}+\b regex finds CaMeL words that:

  • Have at least 1 lowercase letter
  • Have at least 1 uppercase letter
  • Do not follow the X, XXX or Xxxx patterns

Author's SO profile: http://stackoverflow.com/users/3832970/wiktor-stribi%C5%BCew

Submitted by Wiktor Stribiżew
Open Workspace