Regular Expression – Prevent ALL CAPS words in Javascript

/\b[A-Z]{4,}\b/     This expression will detect whole words of at least 4 characters that are composed entirely of uppercase letters.

/[A-Z]{4,}/    This expression will detect four consecutive uppercase letters used anywhere in a string.  I prefer to use this one for text validation because I cannot think of a genuine case where a person would need have four or more uppercase letters used alongside lowercase letters.

This entry was posted in Technical and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s