簡體   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