Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^(?!--)(?![0-9])(?!\-[0-9])[\_\-0-9a-zA-Z]{2,}
/

Description

Validate if class name pass this criteria:

  • A valid name should start with a letter (a-z)[A-Z] , an underscore (_), or a hyphen (-) which is followed by any numbers, hyphens, underscores, letters.
  • A name should be at least two characters long.
  • Cannot start with a digit, two hyphens or a hyphen followed by a number .
Submitted by Agustín Bouillet - 3 days ago