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