patternsyntaxexception

Replacing single '\' with '\\' in Java

元气小坏坏 提交于 2019-12-28 06:58:36
问题 How do I replace a single '\' with '\\' ? When I run replaceAll() then I get this error message. Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Pattern.java:1713) at java.util.regex.Pattern.compile(Pattern.java:1466) at java.util.regex.Pattern.<init>(Pattern.java:1133) at java.util.regex.Pattern.compile(Pattern.java:823) at java.lang.String.replaceAll(String.java:2190) at NewClass.main(NewClass

Android: PatternSyntaxException: Syntax error U_ILLEGAL_ARGUMENT_ERROR

丶灬走出姿态 提交于 2019-12-20 01:38:40
问题 I'm using json-io for converting some JSON data to Java objects: DataTransferContainer dataTransferContainer = (DataTransferContainer)JsonReader.jsonToJava(json); DataTransferContainer is just an object containing some GeoJson elements. It does not matter for this issue. The above code works in JUnit test outside Android, but when I run this on Android, I get this RuntimeException: 12-07 20:12:51.260: E/AndroidRuntime(2002): FATAL EXCEPTION: AsyncTask #1 12-07 20:12:51.260: E/AndroidRuntime

Replace all method throws PatternSyntaxException

大憨熊 提交于 2019-12-02 21:09:20
问题 look at the following code: String comment = "1)FCR pick up in Hong Kong2)Local charges will be paiy in Hong Kong & in HK$.3)Booking:virginiawong@fahkco.com.hk4)FCR&DOC:emilywu@fahkco.com.hkTel:00852-23021977Fax:00852-2730217Transaction865320submittedVirginiaWong(T1281954U005) and Status is INCMP on 10-JUN-11 11.28.45.764386 PM -05:00"; //comment = comment.replaceAll("\\)", "\\\\)"); //comment = comment.replaceAll("\\(", "\\\\("); if(comment == null || comment.length() < 100) { System.out

Replace all method throws PatternSyntaxException

隐身守侯 提交于 2019-12-02 11:49:30
look at the following code: String comment = "1)FCR pick up in Hong Kong2)Local charges will be paiy in Hong Kong & in HK$.3)Booking:virginiawong@fahkco.com.hk4)FCR&DOC:emilywu@fahkco.com.hkTel:00852-23021977Fax:00852-2730217Transaction865320submittedVirginiaWong(T1281954U005) and Status is INCMP on 10-JUN-11 11.28.45.764386 PM -05:00"; //comment = comment.replaceAll("\\)", "\\\\)"); //comment = comment.replaceAll("\\(", "\\\\("); if(comment == null || comment.length() < 100) { System.out.println(); } String[] strArray = comment.split(" "); for (int i = 0; i < strArray.length; i++) { if

Android: PatternSyntaxException: Syntax error U_ILLEGAL_ARGUMENT_ERROR

主宰稳场 提交于 2019-12-01 22:06:07
I'm using json-io for converting some JSON data to Java objects: DataTransferContainer dataTransferContainer = (DataTransferContainer)JsonReader.jsonToJava(json); DataTransferContainer is just an object containing some GeoJson elements. It does not matter for this issue. The above code works in JUnit test outside Android, but when I run this on Android, I get this RuntimeException: 12-07 20:12:51.260: E/AndroidRuntime(2002): FATAL EXCEPTION: AsyncTask #1 12-07 20:12:51.260: E/AndroidRuntime(2002): java.lang.RuntimeException: An error occured while executing doInBackground() 12-07 20:12:51.260: