Why does \R behave differently in regular expressions between Java 8 and Java 9?

后端 未结 2 1454
不知归路
不知归路 2021-02-02 04:44

The following code compiles in both Java 8 & 9, but behaves differently.

class Simple {
    static String sample = \         


        
2条回答
  •  面向向阳花
    2021-02-02 05:39

    It was a bug in Java 8 and it got fixed: JDK-8176029 : "Linebreak matcher is not equivalent to the pattern as stated in javadoc".

    Also see: Java-8 regex negative lookbehind with `\R`

提交回复
热议问题