Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个这样的字符串:“سلام علیکم”,这是一个两个单词的阿拉伯语短语。我想用正则表达式匹配第一个单词。如果是英语,我会测试/^[a-zA-Z]*/。我怎么能用阿拉伯语做到这一点?
/^[a-zA-Z]*/
您可以创建一个仅匹配阿拉伯语的字符类:
/^[\p{Arabic}]*/
这是完整的参考
阿拉伯字符是:
'\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC'