Is C# Split Function different from Java? Why do I get this error when I tried to split the string with a delimiter?
Exception in thread "AWT-EventQueue-0" java.util.regex.PatternSyntaxException: Unmatched closing ')'
)
at java.util.regex.Pattern.error(Pattern.java:1924)
at java.util.regex.Pattern.compile(Pattern.java:1669)
at java.util.regex.Pattern.<init>(Pattern.java:1337)
at java.util.regex.Pattern.compile(Pattern.java:1022)
at java.lang.String.split(String.java:2361)
at java.lang.String.split(String.java:2403)
... <more stacktrace>
Using this code: (tutorial from String Split)
private String GetAccountID(String xStr)
{
String oText = xStr;
String[] oValA = oText.split(")");
String[] oValB = oValA[0].split("(");
return oValB[1];
}
Sample Values:
AccountID sample values:
(100) Department
(100A) Budget
(12-34F) Others
I want to get 100, 100A, 12-34F from the AccountID.
Sample Usage:
String AccID = GetAccountID(AccountID);
Or do you have another solution for this?
One normally would do it by regex replace/find.