首页 > 代码库 > PatternSyntaxException:Syntax error in regexp pattern

PatternSyntaxException:Syntax error in regexp pattern

 Caused by: java.util.regex.PatternSyntaxException: Syntax error in regexp pattern near index 1:
         E/AndroidRuntime(17429): }
         E/AndroidRuntime(17429):  ^
         E/AndroidRuntime(17429):     at java.util.regex.Pattern.compileImpl(Native Method)
         E/AndroidRuntime(17429):     at java.util.regex.Pattern.compile(Pattern.java:400)
         E/AndroidRuntime(17429):     at java.util.regex.Pattern.<init>(Pattern.java:383)
         E/AndroidRuntime(17429):     at java.util.regex.Pattern.compile(Pattern.java:374)
         E/AndroidRuntime(17429):     at java.lang.String.split(String.java:1842)
         E/AndroidRuntime(17429):     at java.lang.String.split(String.java:1823)
         E/AndroidRuntime(17429):     atcom.tang.weather.WeatherMainActivity.onCreate(WeatherMainActivity.java:54)
         E/AndroidRuntime(17429):     at android.app.Activity.performCreate(Activity.java:5046)
         E/AndroidRuntime(17429):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)

         E/AndroidRuntime(17429):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2037)



代码:    temp =temp.split("}")[1];出错

“{” 是关键字符,要加上转意字符
        temp =temp.split("\\}")[1];