Mike Simmons wrote:The patterns given previously probably do work, but not in a split(). That's because in split() you need a regex for the delimiter, not the content between the delimiter. Instead, the regexes given are designed to be used with a Matcher, where you find() each new element. But to do it with split() , you could define a regex that uses lookahead and lookbehind, to find a location in the string that's after a number and before a letter:
Jeff Verdegan wrote:
Gabriel Beres wrote:None of these patterns actually work
That's not surprising, considering you still haven't told us your exact rules.
Also note that ItDoesntWorkIsUseless(⇐click).
I would like to make an array from the following string in java:
PT 3PT 6PT 7PT 8PT 9PT 10PT 11PT 13PT 14PT 15PT 16PT 17PT 19PT 20ST 6ST 7
0 = PT3
1 = PT6
2 = PT7
Jeff Verdegan wrote:If it's null, then instanceof will always be false. There's no way to tell if a null was supposed to be an Integer or a Double or a Date or a JPanel, unless you're in the body of a method that has that type (or a subtype) as an arg. There is no such thing as a null Integer or a null Double.
If you want to distinguish a null that would have been an Integer from a null that could have been a Double, you need either context or metadata. The null itself is not enough.