字符串我有跡象字符串,我想只得到標誌,並把它們在一個字符串數組,這裏是我做了什麼:提取標誌/符號從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