Iam trying to get the string october
from the string ["october"]
i tried with replace method
tagNo = tagNo.replaceAll("\\[|\\]", ""); \\ it prints "october"
i cant replace quote with ""
.
tagNo = tagNo.replaceAll("\\[|\\]", "").replaceAll("\"", "\\\\\"");
not replacing quotes prints \\"october\\"
But i prefer to use a single code
using regex
code how can i get the string with out quotes
and square bracket
You need to slightly correct your regex. You haven't put any rule for removing double quote. Try using this,
tagNo = tagNo.replaceAll("(\\[|\"|\\])+", "");
tagNo = tagNo.replaceAll("[^a-zA-Z]+","");
tagNo = tagNo.replaceAll("\\[\"", "");
tagNo = tagNo.replaceAll("\"\\]", "");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.