![](/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.