I am trying to split a string into multiple strings but rather than using a string just one simple regex pattern, I am trying to use a regex pattern that will split a string into different strings if it detects certain characters, but the characters are different. Instead of splitting the string into different strings, it's giving me each and every individual characters in said string.
String[] splitstr = line.split("([&]{2})?([|]{2})?(!=)?");
Using the above line, I have a variable called line which, as an example, I am putting this line from a file:
:if[input=right || input=Right]:
I am just wondering if there is a way to make this split into
":if[input=right", "input=Right]:"
And if I put in a line like this:
:if[input=right || input=Right && input != null]:
So that it splits into
":if[input=right", "input=Right", "input != null]:"
I was using String#split(regex) for the || symbol and it worked just fine, but now that I want it to split wherever that are || or && or != and I want my code to be efficient and clean and easy to read.