本文介绍了仅大写字母和数字的正则表达式模式,可能带有“列表"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the regex to match words that have the pattern:

任意顺序的数字或大写 * 3(+可能的列表"在末尾)

例如,

OP3
G6H
ZZAList
349
127List

都是有效的,而

a3G
P-0List
HYiList
def
YHr

都是无效的.

推荐答案

你可以使用正则表达式:

You can use the regex:

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

解释:

^        : 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

看看

这篇关于仅大写字母和数字的正则表达式模式,可能带有“列表"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 07:10