i am first to this site. I want to split a string without the characters that matched in regex of string split method in java.
The string for splitting is (for eg.) : "conditional&&operator and ampersand&Symbol."
My regex-expression for spit is : "[^\\&]\\&[^\\&]"
My expectation is : [conditional&&operator and ampersand, Symbol]
But, the output is : [conditional&&operator and *ampersan, ymbol*]
The code i used is:
String s = "conditional&&operator and ampersand&Symbol.";
String[] sarr = s.split("[^\\&]\\&[^\\&]");
System.out.println(Arrays.toString(sarr));
So, please tell me what regex i should use to get the expected output, that is without the additional characters removed.