如何检查字符串的@pattern 注解 2-2E454

How to check @pattern annotation for a string 2-2E454

如何检查包含字母数字和 - 如 (1-1k546) 的字符串的 @pattern 注释。

\d-[0-9a-zA-Z]+

\d match a digit [0-9]
- matches the character - literally
[0-9a-zA-Z]+ match a single character present in the list below
    Quantifier: + Between one and unlimited times, as many times as possible, giving back as needed [greedy]
    0-9 a single character in the range between 0 and 9
    a-z a single character in the range between a and z (case sensitive)
    A-Z a single character in the range between A and Z (case sensitive)