-
符号可以被视为运算符或负号。如果-
位于开头,则应将其视为负号和字符串中的减法。这仅适用于-
符号,而+
始终是添加符号。我怎样才能做到这一点?
输入:
-23-23+4=F1Qa;
+23-23+4=F1Qa;
输出:
["-23","-","23","+","4","=","F","1","Q","a",";"]
["+", "23","-","23","+","4","=","F","1","Q","a",";"]
这是我迄今为止尝试过的
String regx = (?:# .*? #:?)|(?!^)(?=\\D)|(?<=\\D)(?=\\d-)
String[] splits = inputString.split(regx);