Share via


Invalid range in character set (JavaScript)

You attempted to create a regular expression with an invalid character set range. Character sets must range from single characters only, such as a-z or 0-9; you cannot include character classes such as \w in a character set. The first character in the range must also come before the second character in the range. For example:

var good = /[a-z]/;     // A valid character range - a comes before z.  
var notGood = /[z-a]/;  // An invalid character range - z does not come before a.  

To correct this error

  • Use only single characters to compose your regular expression character set, and make sure they are in the correct order.

See also

Regular Expression Object
Regular Expression Syntax (JavaScript)