Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^\s*\d*[a-zA-Z]\d*\s*$
/

Description

I need to match a pattern as follows with the added limitation that the match must be exactly 7 characters long: /^\d*[a-zA-Z]\d*$/ In words, this is a 7 character sequence of 6 digits and one alphabetic character in any order. How do I limit the overall length to 7 using regex? Thanks!

Submitted by Andy S - 10 years ago