I have some code which has some perl like behavior and allows me to split a line with some separators onto a head and tail specifying an index. A negative index will start from the end of the string and will make the tail the head, handy if you're not sure on the number of columns in your list.
All works beautiful and as expected however, the split uses regexes to match the column separators, works for ~ but not for "|", which is treated as a regex special character, I may be able to pass in "\\|" but that upsets the join feature. So my question is: is there a way to use split only on normal "string tokens" or are there other clever ways to get divide a string in the documented way.
Thanks in advance. jeroen. My question is there a way to make the split none regex like
The \Q...\E thing is a carryover from Perl; there's no good reason to use it in Java, considering how much more complicated it is to work with. I've never understood why they used it in the quote() method, but at least we don't have to deal with it.