by le cool cat » Sun Apr 08, 2012 4:05 pm
i am going to assume you know regex. if you do not, go here.
the regex \\p{Punct}
is equivalent to the character class
[!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]
or to escape this correctly in java...
[!\"#$%&'()*+,\\-./:;<=>?@[\\\\]^_`{|}~]
here's how i show my teammates how to handle splits.
highlight matches, or in the case at UIL circle them, or do something to distinguish them. in this case, i will separate consecutive matches with a space.
$ $ $arrows&hearts&candies$$$
for the split case, trailing matches do not matter. so we can ignore them.
$ $ $arrows&hearts&candies
if a string starts with a match, it will create an empty string for the first element. after that, each element is defined as what is between the matches. if two matches are right next to each other, it creates an empty string. so in this case (matches are in parenthesis)
("")$("")$("")$(arrows)&(hearts)&(candies)
our final array, if printed with the Arrays.toString() method would look like this
[ , , , arrows, hearts, candies]
the element at position 4 is hearts, and the length is 6
2012 State Champion in Computer Science (4A)
2013 State Qualifier in Science (4A, results pending)
A:318 (96/120/102)
B: 298 (76/120/102)
D1: 328 (88/120/120)
R: 270 (90/112/68)
S: 360