【发布时间】:2021-10-20 17:25:39
【问题描述】:
有没有办法设置 u 标志从而启用 unicode 正则表达式模式?
我需要匹配Straßer、Müller、Adèle、Yiğit 等名称。
如果我可以在 JSON 模式中使用纯 JS,/\p{L}+/u 或 new RegExp('\\p{L}+', 'u') 将适用于我的情况。
6.3.3。模式
此关键字的值必须是字符串。根据 ECMA-262 正则表达式方言,此字符串应该是有效的正则表达式。
我发现了这个:How to match a Unicode letter with a JSON Schema pattern (regular expression)。结果太糊涂了。如果设置了u 标志,JavaScript/ECMA 脚本可以按预期处理\p{L}。
【问题讨论】:
标签: json regex unicode jsonschema letter