[英]Hebrew text parsing using regex in Java
我正在嘗試解析希伯來語文本,但沒有獲得任何成功。 這里有人可以幫忙嗎?
String hebrewSearhString = "חן";
//String regexHebrewPattern = "([\\u0591-\\u05F4\\s]+)"; // Tried this too, but same no success
String regexHebrewPattern = "([\\p{InHebrew}]+)";
Pattern patternHebrew = Pattern.compile(regexHebrewPattern, Pattern.UNICODE_CASE);
Matcher matcherHebrew = pattern.matcher(hebrewSearhString);
if(matcherHebrew.matches()) {
System.out.println("Whole -"+ matcherHebrew.group(0));
//System.out.println("Group 1 -"+ matcherHebrew.group(1));
//System.out.println("Group 2 -"+ matcherHebrew.group(2));
}
Result : "If" condition doesn't gets to TRUE
謝謝
這個,
Matcher matcherHebrew = pattern.matcher(hebrewSearhString);
應該
Matcher matcherHebrew = patternHebrew.matcher(hebrewSearhString);
我得到了輸出,
Whole -חן
因為if
評估結果為true
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.