I want to split a string with space-character but ignoring the space between two brackets.
The code i used is:
String s = "hello (split this) string";
String reg = "(?<=([^\\(].*))( )(?=(.*[^\\)]))";
System.out.println(Arrays.toString(s.split(reg));
My expected output is:
[hello , (split this) , string]
but i get this error
Exception in thread "main" java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 12 (?<=([^(].))z(?=(.*[^)])) *
I need a regex to get the expected output.
So, somebody please help.