java中替换问号

 

String srt="abc?abc"; str.replaceAll("?", "#"); 会提示这样的错误 Dangling meta character '?' near index 0 ? ^ at java.util.regex.Pattern.error(Unknown Source) at java.util.regex.Pattern.sequence(Unknown Source) at java.util.regex.Pattern.expr(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.util.regex.Pattern.(Unknown Source) at java.util.regex.Pattern.compile(Unknown Source) at java.lang.String.replaceAll(Unknown Source) str.replaceAll("[?]", "#"); 这样写就可以了

你可能感兴趣的:(Ajax,Web技术)