要使用Java正则表达式提取中英文句子,可以使用以下正则表达式模式:
       
       
         
String pattern = "([\\w\\s]+[.!?]+[\\w\\s])";
       
这个模式可以匹配一个或多个中英文单词和空格,后面跟着一个句号、感叹号或问号,然后再跟着一个或多个中英文单词和空格。
下面是一个Java代码示例,演示如何使用这个正则表达式模式来提取中英文句子:
       
       
         
import Matcher;
import Pattern;
正则表达式提取中文
public class SentenceExtractor {
public static void main(String[] args) {
String text = "This is a sentence. 这是一个句子。 123456";
String pattern = "([\\w\\s]+[.!?]+[\\w\\s])";
Pattern r = Patternpile(pattern);
Matcher m = r.matcher(text);
while (m.find()) {
System.out.up());
}
}
}
       
输出结果:
       
       
         
This is a sentence.
这是一个句子。