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

后端 未结 1 801
温柔的废话
温柔的废话 2020-12-24 11:47

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

Number or Capital in any order * 3 (+possible \'List\' on the end)

For example,

相关标签:
1条回答
  • 2020-12-24 12:51

    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

    0 讨论(0)
提交回复
热议问题