问题描述
我来自这个帖子
如何用reg exp匹配阿拉伯语单词?(没有回答我的问题)
我试过了
^[\p{Arabic} ]+$
收到
'解析错误',原因:'无效的转义序列@pos 3:^[\▶p{阿拉伯语}]+$'
我也试过
^[\u0621-\u064A\s]+$
'解析错误',原因:'无效字符范围@pos 7:^[\u062▶1-\u064A\s]+$'
我也试过
^[\u0621-\u064A]+$
'解析错误',原因:'无效字符范围@pos 7:^[\u062▶1-\u064A]+$'
我需要 ^[A-Za-z ]+$ 接受阿拉伯字符.
提前致谢!
这解决了我的问题
只有空格的阿拉伯文本:
^[ء-يء-ي ]+$
仅限阿拉伯文字:
^[ء-ي]+$
阿拉伯文字和数字:
^[ء-ي٠-٩]+$
用于英文文本和阿拉伯文本
^[A-Za-zء-ي]+$
用于英语和阿拉伯语文本和数字
^[A-Za-z0-9ء-ي٠-٩]+$
使用unicode会崩溃
I come from this posts
Regular Expression Arabic characters and numbers only
How to match arabic words with reg exp? (didn't answer my question)
I've tried
^[\p{Arabic} ]+$
and received
I've also tried
^[\u0621-\u064A\s]+$
I've also tried
^[\u0621-\u064A]+$
I need ^[A-Za-z ]+$ that accepts arabic characters.
Thanks in advance!
This solved my issue
Arabic text with spaces only:
Arabic text only:
Arabic text and digits:
for English text and arabic text
for English and Arabic Text and digits
It will crash if you use unicode
这篇关于iOS 正则表达式阿拉伯语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!