iOS 正则表达式阿拉伯语 [英] iOS regular expression arabic
问题描述
我来自这个帖子
如何用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
'Parse error', reason: 'Invalid escape sequence @ pos 3: ^[\ ▶p{Arabic} ]+$'
I've also tried
^[\u0621-\u064A\s]+$
'Parse error', reason: 'Invalid character range @ pos 7: ^[\u062 ▶1-\u064A\s]+$'
I've also tried
^[\u0621-\u064A]+$
'Parse error', reason: 'Invalid character range @ pos 7: ^[\u062 ▶1-\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
^[A-Za-zء-ي]+$
for English and Arabic Text and digits
^[A-Za-z0-9ء-ي٠-٩]+$
It will crash if you use unicode
这篇关于iOS 正则表达式阿拉伯语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!