字符串我有迹象字符串,我想只得到标志,并把它们在一个字符串数组,这里是我做了什么:提取标志/符号从Java中
String str = "155+40-5+6";
// replace the numbers with spaces, leaving the signs and spaces
String signString = str.replaceAll("[0-9]", " ");
// then get an array that contains the signs without spaces
String[] signsArray = stringSigns.trim().split(" ");
然而signArray的第二个元素是一个空格,[+, - - ,+]
谢谢你的时间。
https://stackoverflow.com/questions/17516049/java-removing-numeric-values-from-string – soorapadman