首页

java替换replaceAll方法报“java.util.regex.PatternSyntaxException: Unexpected internal error near index 1”错误

标签:PatternSyntaxException,replaceAll异常     发布时间:2021-09-04   

一、异常描述

关于java.lang.String的replaceAll替换斜杠问题报“Exception in thread "Timer-0" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1”错误异常,详细错误日志

Exception in thread "Timer-0" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1@b@\@b@ ^@b@	at java.util.regex.Pattern.error(Pattern.java:1924)@b@	at java.util.regex.Pattern.compile(Pattern.java:1671)@b@	at java.util.regex.Pattern.<init>(Pattern.java:1337)@b@	at java.util.regex.Pattern.compile(Pattern.java:1022)@b@	at java.lang.String.replaceAll(String.java:2162)@b@	at com.xwood.engine.filecopy.FileIOServiceImpl.synFile(FileIOServiceImpl.java:239)@b@	at com.xwood.engine.filecopy.FileIOServiceImpl.synFile(FileIOServiceImpl.java:249)@b@	at com.xwood.engine.filecopy.FileCopyStartJobMain.copyTo(FileCopyStartJobMain.java:34)@b@	at com.xwood.engine.filecopy.FileCopyStartJobMain.jobWBSEntry(FileCopyStartJobMain.java:22)@b@	at com.xwood.engine.common.bootstart.Root5sTimerMain$1.run(Root5sTimerMain.java:53)@b@	at java.util.TimerThread.mainLoop(Timer.java:555)@b@	at java.util.TimerThread.run(Timer.java:505)

二、解决方法

下面replaceAll替换方法

sourceFullDir=sourceFullDir.replaceAll("\\", "/");

改为

sourceFullDir=sourceFullDir.replaceAll("\\\\", "/");
@b@
  • <<相关内容>>
<<热门下载>>