Can someone help me in understanding how split in java works.I have the following code
String temp_array[]; String rates = "RF\\0.6530\\0.6535\\D"; String temp = rates.substring(1, rates.length()); System.out.println(temp);// prints F\0.6530\0.6535\D String regex = "\\"; temp_array = temp.split(regex); String insertString = "INSERT into table values("+temp_array[0]+","+temp_array[1]+","+temp_array[2]+","+temp_array[3]+")";
however in split function i get the following exception
Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1 \ ^ at java.util.regex.Pattern.error(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.util.regex.Pattern.<init>(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.lang.String.split(Unknown Source) at java.lang.String.split(Unknown Source) at simple_hello.main(simple_hello.java:15)
java string arrays split regex
ayush
source share