Regular Expressions 101

Community Patterns

match 8 character device name with restrictions

1

Regular Expression
ECMAScript (JavaScript)

/
^[A-Za-z][A-Za-z0-9-_]{0,6}[A-Za-z0-9]{0,1}$
/
gmi

Description

Charset is: 0 1 2 3 4 5 6 7 8 9 - _ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z

Rules for string:

  1. String can start only with a letter.
  2. String can end with a letter or a number.
  3. String can NOT start or end with a '-' or '_'.
  4. String can be up to 8 characters.
Submitted by anonymous - 8 years ago