(?<=^|[a-z]-|[sp{punct}&&[^-]])([a-z][a-z0-9_]*-d+)(?![^w_])
我使用库 reregexp2
这个 re 在 go 中不起作用,会报错:
regexp2: Compile(`(?<=^|[a-z]-|[sp{Punct}&&[^-]])([A-Z][A-Z0-9_]*-d+)(?![^W_])`): error parsing regexp: unknown unicode category, script, or property 'Punct' in `(?<=^|[a-z]-|[sp{Punct}&&[^-]])([A-Z][A-Z0-9_]*-d+)(?![^W_])`
希望能正常执行
如果你看一下 Java正则表达式模式文档
,您会看到 p{Punct}
是 Punctuation: One of !"#$%&'()*+,-./:;<=>?@[] ^_{|}~
p{Punct} 标点符号:!"#$%&'()*+,-./:;<=>?@[]^_`{|}~
之一那么您需要将其转换为 go 正则表达式,检查 regexp 语法文档