Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java中使用正则表达式的希伯来文文本解析_Java_Regex_Parsing_Hebrew - Fatal编程技术网

Java中使用正则表达式的希伯来文文本解析

Java中使用正则表达式的希伯来文文本解析,java,regex,parsing,hebrew,Java,Regex,Parsing,Hebrew,我试图解析希伯来文文本,但没有获得任何成功。这里有人能帮忙吗 String hebrewSearhString = "חן"; //String regexHebrewPattern = "([\\u0591-\\u05F4\\s]+)"; // Tried this too, but same no success String regexHebrewPattern = "([\\p{InHebrew}]+)"; Pattern patternHebre

我试图解析希伯来文文本,但没有获得任何成功。这里有人能帮忙吗

    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的计算结果为真。

谢谢@Elliot。那是一个愚蠢的错误。在这段代码上面,我使用“pattern”变量还有其他用途。