“Invalid escape sequence (valid ones are \b \t \n \f \r \” \' \\ )" syntax error

后端 未结 3 683
夕颜
夕颜 2021-01-14 13:15

I wrote code for matching filepath which have extenstion .ncx ,

 pattern = Pattern.compile(\"$(\\\\|\\/)[a-zA-Z0-9_]/.ncx\");
 Matcher matcher = pattern.math         


        
3条回答
  •  既然无缘
    2021-01-14 13:51

    In java \ is a reserved character for escaping. so you need to escape the \.

    pattern=Pattern.compile("$(\\\\|\\/)[a-zA-Z0-9_]/.ncx");
    

提交回复
热议问题