Erlang 中的正则表达式。在结果列表中添加额外的匹配项

Regular Expressions in Erlang. Adding additional match in a result list

我正在学习如何使用正则表达式在 Erlang 中获取字符串。 请向我解释为什么当我对值为0到255的序列的元素列表执行正则表达式时,大于127的值落入结果列表?

Expected = true,
ValidCharacterList = lists:seq(0, 255),

RegularExpression = "[[:ascii:]]",
{ok, MP} = re:compile(RegularExpression),
{match, _} = re:run(ValidCharacterList, MP),
Result = true,
?assertEqual(Expected, Result).

结果是该序列的所有元素(从 0 到 255)。

Full code example.

More code examples.

POSIX的:ascii:定义为[\x00-\x7F]。但是请注意,Erlang states

There is another character class, ascii, that erroneously matches Latin-1 characters instead of the 0-127 range specified by POSIX. This cannot be fixed without altering the behaviour of other classes, so we recommend matching the range with [[=12=]-\x7f] instead.