希伯来语和符号的正则表达式 [英] Regex for Hebrew and symbols
本文介绍了希伯来语和符号的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个只能接受希伯来字母和至少一个空格字符的表达式.
I need an expression that can accept only Hebrew letters and at least one space char.
我为希伯来字母尝试了这个,但它不匹配带有希伯来文本和空格的句子:
I tried this for Hebrew letters, but it doesn't match sentences with Hebrew text and spaces:
result = Regex.IsMatch(txtName.Text, @"[\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA]");
如何在正则表达式中表示所有希伯来字母和至少一个空格字符?
How can I represent all the Hebrew letters and at least one space char in regEx?
推荐答案
您正在寻找类似于 @"[\p{IsHebrew} ]+"
的表达式 - 至少一个字符是希伯来语或空间.匹配整个句子 - 添加开始/结束锚点 - @"^[\p{IsHebrew} ]+$"
.
You are looking for expression similar to @"[\p{IsHebrew} ]+"
- at least one character either Hebrew or space. To match whole sentence - add begin/end anchors - @"^[\p{IsHebrew} ]+$"
.
详细解释见希伯来语或英语的正则表达式 和 C#/.Net 中的字符类正则表达式.
这篇关于希伯来语和符号的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文