String.replaceAll没有RegEx [英] String.replaceAll without RegEx
本文介绍了String.replaceAll没有RegEx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想替换字符串中子字符串的所有实例,但 String.replaceAll()
只接受模式。我来自前一场比赛的字符串。是否有可能在我拥有的模式中添加转义符,或者在另一个接受文字字符串而不是模式的类中有 replaceAll()
的版本?
I'd like to replace all instances of a substring in a string but String.replaceAll()
only accepts a pattern. The string that I have came from a previous match. Is it possible to add escapes to the pattern that I have or is there a version of replaceAll()
in another class which accepts a literal string instead of a pattern?
推荐答案
只需使用 与string.replace(的CharSequence,CharSequence中)
而不是 replaceAll
。
这篇关于String.replaceAll没有RegEx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文