作者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/cn.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