简体   繁体   English

希伯来语和符号的正则表达式

[英]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?如何在 regEx 中表示所有希伯来字母和至少一个空格字符?

You are looking for expression similar to @"[\\p{IsHebrew} ]+" - at least one character either Hebrew or space.您正在寻找类似于@"[\\p{IsHebrew} ]+"表达式 - 至少一个字符,希伯来语或空格。 To match whole sentence - add begin/end anchors - @"^[\\p{IsHebrew} ]+$" .要匹配整个句子 - 添加开始/结束锚点 - @"^[\\p{IsHebrew} ]+$"

For detailed explanation see regular expression with hebrew or english and C#/.Net Character Classes in Regular Expressions .有关详细说明,请参阅正则表达式中的带有希伯来语或英语的正则表达式C#/.Net 字符类

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM