c****r 发帖数: 185 | 1 To represent a predefined character in regular expression, just precede it
with \
Since \ is also a special character in java strings, you need another \
For example, "." should be written as "\\." | l********r 发帖数: 140 | 2 that works. Thanks.
But as a curious, I just want to know how to write it if I want to repalce a
number \?
Such as I want to replace "\\\\\\\\" in a string with " ".
【在 c****r 的大作中提到】 : To represent a predefined character in regular expression, just precede it : with \ : Since \ is also a special character in java strings, you need another \ : For example, "." should be written as "\\."
| c****r 发帖数: 185 | 3 The regex for a number of \ is \\+
So the java string should be "\\\\+"
where
【在 l********r 的大作中提到】 : that works. Thanks. : But as a curious, I just want to know how to write it if I want to repalce a : number \? : Such as I want to replace "\\\\\\\\" in a string with " ".
|
|