繁体   English   中英

在Java中使用正则表达式进行希伯来语文本解析

[英]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.

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