Regex pattern for capital letters and numbers only, with possible ‘List’

You can use the regex:

^[A-Z0-9]{3}(?:List)?$

Explanation:

^        : Start anchor
[A-Z0-9] : Char class to match any one of the uppercase letter or digit
{3}      : Quantifier for previous sub-regex 
(?:List) : A literal 'List' enclosed in non-capturing paranthesis
?        : To make the 'List' optional
$        : End anchor

See it

Leave a Comment