Pet*_*ton 7

这是使用正则表达式注释模式的解释,因此这个扩展形式本身可以用作正则表达式:

(?x)      # flag to enable comment mode
^         # start of line/string.
(?!-)     # negative lookahead for literal hyphen (-) character, so fails if the next position contains one.
[a-z\d\-] # character class matches a single alpha (a-z), digit (\d) or hyphen (\-).
{1,100}   # match the above [class] upto 100 times, at least once.
$         # end of line/string.
Run Code Online (Sandbox Code Playgroud)

简而言之,它匹配最多100个小写字母数字或连字符,但第一个字符不能是连字符.

可能是试图验证序列号或类似的序列号,但它太笼统,无法确定.


并非所有正则表达式引擎都支持负向前瞻.如果你想弄清楚它正在做什么以适应没有负面前瞻的引擎,你可以使用:

^[a-z\d][a-z\d-]{0,99}$
Run Code Online (Sandbox Code Playgroud)