Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/323.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.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 正则表达式在每个句点后拆分一段,但不';t在缩写后拆分_Java_Regex - Fatal编程技术网

Java 正则表达式在每个句点后拆分一段,但不';t在缩写后拆分

Java 正则表达式在每个句点后拆分一段,但不';t在缩写后拆分,java,regex,Java,Regex,我需要把一段话分成几个句子。这意味着在每一个时间段之后拆分它,但是我还必须考虑句子可以包含缩写,例如ANNV。利姆诺。我用lookback生成了一个正则表达式来匹配这个时期之前的任何缩写。我动态创建regex,如下所示: String regex = "(?<!abbrev1)(?<!abbrev2)\\."; //abbrev 1 and abbrev 2 are just examples the regex I use is much longer //

我需要把一段话分成几个句子。这意味着在每一个时间段之后拆分它,但是我还必须考虑句子可以包含缩写,例如ANNV。利姆诺。我用lookback生成了一个正则表达式来匹配这个时期之前的任何缩写。我动态创建regex,如下所示:

    String regex = "(?<!abbrev1)(?<!abbrev2)\\.";
    //abbrev 1 and abbrev 2 are just examples the regex I use is much longer
    //Then I split the paragraph

    paragraph.split(regex);

String regex=“(?我建议您包括句点)使用缩写,而不是单独表示。或者,您可以使用当前的正则表达式样式将
U.S.A.
表示为
U.S.A.

我怀疑正则表达式是否适合这种情况。它需要某种类型的解析器。正则表达式功能强大,但并不神奇。使用
[A-Z]进行反向查找如何
?我不能真正使用[A-Z],因为缩略语是非常随机的,那么关于如何进行拆分有什么建议吗?有没有像
A.B.C
(空格靠近
)这样的缩略语不应该拆分?