Regular Expressions 101

Community Patterns

PasCamelCase

0

Regular Expression
PCRE2 (PHP >=7.3)

/
^([A-Z](([A-Z]{1,2}[a-z0-9]+)+([A-Z]{1,3}[a-z0-9]+)*[A-Z]{0,3}|([a-z0-9]+[A-Z]{0,3})*|[A-Z]{1,2}))$|^([a-z][a-z0-9]*(([A-Z]{1,3}[a-z0-9]+)*[A-Z]{0,3}|([a-z0-9]+[A-Z]{1,3})*|[A-Z]{1,3}))$
/
gm

Description

PasCamelCase

A combination of pascal and camel case. PasCamelCase is a lenient case style that is allows a phrase to use either pascal case or camel case rules.

In addition, PasCamelCase allows for 2-3 letter acronyms such as IOStream, StreamIO, DeviceID, deviceID, AwsVPC, awsVPC, ```serialNO``. This rule is inspired by Microsoft's Capitalization Convention

Rules

For a phrase to be valid PasCamelCase it:

  • MUST start with a lower or upper case alphabet (a through z or A through Z)
  • MUST have no spaces, punctuation or special characters
  • MAY contain digits 0 - 9
  • CAN have at most 3 uppercase alphabets in a row
  • CAN end in an uppercase alphabet

The following are all valid PasCamelCase phrases:

  • a
  • aG
  • camelCase
  • camelCasE
  • aGa
  • alphabet
  • camelCase
  • cP3
  • a1
  • a1G
  • a123
  • camelCa1
  • camel01C
  • streamIO
  • deviceID
  • serialNO
  • awsVPC
  • A
  • Ag
  • AaA
  • Aabc123
  • Pascal2Case
  • Pascal2CaseA
  • Mode2A
  • Mode2A2
  • Mode2A2A
  • SupportsIpv6OnIos
  • IOStream
  • StreamIO
  • IOStream
  • DeviceID
  • AwsVPC
  • DeviceSNS
  • CreateAMode
  • CreateBMode
  • ABCabcABCabc
  • ABCabcABCabcA
  • Camel01CC01

The following are not PasCamelCase phrases:

  • 2PascalCase
  • CamelCa_1
  • HELLO
  • HTMLParser
  • AabcABCDabcABCD
  • streamIOIO
Submitted by anonymous - 2 years ago (Last modified 2 years ago)