![](/img/trans.png)
[英]Check String whether it contains certain charecters Java Regular Expression
[英]regular expression to get string in between special charecters
我试图从替换["october"]
字符串中获取字符串october
tagNo = tagNo.replaceAll("\\[|\\]", ""); \\ it prints "october"
我无法将引号替换为""
。
tagNo = tagNo.replaceAll("\\[|\\]", "").replaceAll("\"", "\\\\\"");
不替换报价打印\\"october\\"
但我更喜欢使用一个代码
使用regex
代码如何获取不带quotes
和square bracket
的字符串
您需要稍微更正您的正则表达式。 您尚未制定任何删除双引号的规则。 试试这个
tagNo = tagNo.replaceAll("(\\[|\"|\\])+", "");
tagNo = tagNo.replaceAll("[^a-zA-Z]+","");
tagNo = tagNo.replaceAll("\\[\"", "");
tagNo = tagNo.replaceAll("\"\\]", "");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.