ArrayOutOfBoundsException
使用すると奇妙になりreplaceFirst
ます:
"this is an example string".replaceFirst("(^this )", "$1\\") // throws ArrayOutOfBoundsException
"this is an example string".replaceFirst("(^this )", "$1") // works fine
私はこの文字列を達成しようとしています:
"this \is an example string"
置換文字列にエスケープされたバックスラッシュを挿入しようとすると、ArrayOutOfBoundsException が発生するのはなぜですか? 違いがある場合、これはAndroidで発生しています
これは、例外のイデオンの例です。
logcat 例外スタック トレースは次のとおりです。
java.lang.ArrayIndexOutOfBoundsException: java.util.regex.Matcher.appendEvaluated(Matcher.java:149) で index=14、java.util.regex.Matcher.appendReplacement(Matcher.java:111) で java.util.regex. java.lang.String.replaceFirst(String.java:1793) の Matcher.replaceFirst(Matcher.java:304)