作者crowley ()
看板java
標題[問題] 字串符號檢查的問題
時間Thu Apr 19 17:55:22 2018
if (wordSt.endsWith("(")){
theStack.push(wordSt.charAt(0));
}
else if(wordSt.endsWith(")")){
theStack.pop();
}
要判斷字串中的括號是否正確
現在我只能正確判斷( )而已
但是我想要[ ]和{ }也能判斷的話
該怎麼處理呢?
感謝各位大大
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 1.163.213.168
※ 文章網址: https://webptt.com/m.aspx?n=bbs/java/M.1524131725.A.8C8.html
※ 編輯: crowley (1.163.213.168), 04/19/2018 17:56:22
1F:推 tong87: 用Regex 04/19 19:32
我現在練習堆疊 所以想用堆疊的方式做
感謝大大
※ 編輯: crowley (1.163.213.168), 04/19/2018 19:45:12
2F:推 qui1218: Regular expression 04/19 23:17
3F:→ inxbone: 就遇到右邊的括弧判斷pop出來的值符不符合 04/20 00:19