仅限大写字母和数字的正则表达式,可能有"列表"

Iai*_*ard 23 regex numbers capitalization

匹配具有该模式的单词的正则表达式是什么:

任何顺序的数字或资本*3(最后+可能'列表')

例如,

OP3
G6H
ZZAList
349
127List
Run Code Online (Sandbox Code Playgroud)

都是有效的,而

a3G
P-0List
HYiList
def
YHr
Run Code Online (Sandbox Code Playgroud)

都是无效的.

cod*_*ict 46

你可以使用正则表达式:

^[A-Z0-9]{3}(?:List)?$
Run Code Online (Sandbox Code Playgroud)

说明:

^        : 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
Run Code Online (Sandbox Code Playgroud)

看见

  • 这是一种享受,并且感谢包括一个解释,正则表达式现在开始对我更有意义.虽然不是很多......; P. (4认同)