正则表达式常规模式匹配不适用于相应的文本文件



对于特定的单词,我必须获取完整的句子/句子(直到句号)。其中不包括小数点(3.75)。

示例

具体词:"阿巴西普"

段落

  Review of Systems:
General:  Complains of chills, sweats, and malaise; denies fever, anorexia, fatigue, weakness, weight loss, and sleep                                          
disorder.
CV: Denies difficulty breathing at night, near fainting, chest pain or discomfort, racing/skipping heart beats, fatigue, 
lightheadedness, shortness of breath with exertion, palpitations, swelling of hands or feet, difficulty breathing while lying 
down, fainting, leg cramps with exertion, bluish discoloration of lips or nails, and weight gain 3.785 **Abatacept**.
Resp: Complains of cough; denies sleep disturbances due to breathing, shortness of breath, coughing up blood, chest 
discomfort, wheezing, excessive sputum, and excessive snoring.

从段落中,我想要与阿巴西普单词匹配的句子/句子。这句话是:

CV: Denies difficulty breathing at night, near fainting, chest pain or discomfort, racing/skipping heart beats, fatigue, 
    lightheadedness, shortness of breath with exertion, palpitations, swelling of hands or feet, difficulty breathing while lying 
    down, fainting, leg cramps with exertion, bluish discoloration of lips or nails, and weight gain 3.785 **Abatacept**.

法典:

word_re = "((\.(\s|\r).*)|(((?!\.\s).)*))(\b(Abatacept)\b.*?)((\.\s)|(\.\D)|(\.$))";
Pattern re = Pattern.compile(word_re ,Pattern.MULTILINE | Pattern.COMMENTS |  Pattern.CASE_INSENSITIVE);
                Matcher match = re.matcher(textString);
                String sentenceString="";
                while (match .find()) {
                    sentenceString = match.group(1);
                    System.out.println(sentenceString);
                }

你能建议我吗?因此,我可以从该特定单词所在的文本文件中获取完美的句子/句子。谢谢。

我不确定 java,但您可以使用此正则表达式:

(.*bAbataceptb.*[b(.s)])

演示

最新更新