I've written a Java class which must pull elements out of a string containing newlines. As a first step the code must split the input string by newline and place the results into an array. This is all working fine except in one specific case. I'm using the following code to perform the split:
String lines[] = inputText.split("[\\r?\\n\\r]+");
The issue I'm having is with the following line:
##INFO=<ID=DS,Number=0,Type=Flag,Description=""removed?"">"
It results in two lines:
##INFO=<ID=DS,Number=0,Type=Flag,Description=""removed
"">"
It is splitting on the question mark. Could anyone point me in the right direction as to why this is happening? Inside a regex doesn't a '?' indicate 0 or 1 occurrence? Is this not an acceptable way to split by newline?