0

8 启用了 pcre,我正在尝试匹配 \p{Po} 组加上一堆其他的东西。

我想排除 & 字符。如何将特定角色排除在课程之外?

-- lua btw    
local utf8_general_punctuation_reg = "[\\p{Po}\\p{Cc}\\p{Cs}\\p{Pc}\\p{Pe}\\p{Ps}\\p{Pf}\\p{Pi}\\p{Sm}\\x{2100}-\\x{2123}\\x{2600}-\\x{26ff}]+"

提前致谢!

BTW \p{Po} 适用于 utf8 http://www.fileformat.info/info/unicode/category/Po/list.htm

只需从以下答案中添加有效的内容:

local utf8_general_punctuation_reg = "[\\p{Po}\\p{Cc}\\p{Cs}\\p{Pc}\\p{Pe}\\p{Ps}\\p{Pf}\\p{Pi}\\p{Sm}\\x{2100}-\\x{2123}\\x{2600}-\\x{26ff}]+(?<!(&|\\.|:))"
4

1 回答 1

1

You can use negative lookbehind for this. I'm not familiar with pcre syntax.

[abc](?<!b)

That regex first allows a or b or c, just look the Unicode Property allows different characters, and then disallow the b character with negative lookbehind.

The regex above will match a and c in the end but not b.

于 2012-05-28T18:44:00.387 回答