I have a string that I want to divide into an array:
I tried the following regular expression: and it works in the testers (pattern in OSX) but it divides this string into: < How do I get the following:? A, 2B, 3C] This test code is: < Use div code = "post-text" itemprop = "text"> SEQUENCEï ¼ ?? 1Aa ???? 2Ba ???? 3C
((*. * \ S) | ([\ X {2192}] *))
1. \ X {2192} Aero Mark 2 is. There is a place after the colon, I used it as a reference to match the first part
[, 1, a, 2, b, 3, c]
string str = "SEQUENCEï¼" ?? 1A "??? ??? -3C "; // Note that colon system.out.println (Arrays.toString (str.split (" (. * \\ s) | ([\\ x {2192}] *) after an extra space As stated in the post of Richard Seats, the main problem with regex is that it should be that
+ instead of
+ Additionally, your résx should be further improved. Instead of
\\ x {2192} , use
\ u2192 and because it is a You do not need to keep it in a character square (
[...] ), you can use directly
\ u2192 + . / Li>
|
. * \\ s and
\ u2192 + , you will not need it there Either parentheses, your last expression is simply
. * \\ s | \ u2192 + ".
No comments:
Post a Comment