由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - Re: wrong!!! Re: 有没有 replaceall for Stri
相关主题
wrong!!! Re: 有没有 replaceall for String?java str.replaceAll("\n", "") doesn't work
有没有 replaceall for String?如何确保每次读入的字符串都是unique的
why doesn't replaceAll work?how to run java program in dos?
问个String:replaceALL的问题几个问题
问一个Java regexp的题问个ArrayList的问题
有什么办法高效的进行replaceAllHelp me: jsp tag 问题
java 截取一部分stringStupid IBM JVM: operator precedence
我自己编了个Java面试题What's your habit to document this?
相关话题的讨论汇总
话题: stri话题: replaceall话题: character话题: wrong话题: since
进入Java版参与讨论
1 (共1页)
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 " ".

1 (共1页)
进入Java版参与讨论
相关主题
What's your habit to document this?问一个Java regexp的题
Do you guys use lex to parsing input?有什么办法高效的进行replaceAll
现在有些迷惑了java 截取一部分string
what is wrong? Pattern.compile("[ \t\n\x0B\f\]")我自己编了个Java面试题
wrong!!! Re: 有没有 replaceall for String?java str.replaceAll("\n", "") doesn't work
有没有 replaceall for String?如何确保每次读入的字符串都是unique的
why doesn't replaceAll work?how to run java program in dos?
问个String:replaceALL的问题几个问题
相关话题的讨论汇总
话题: stri话题: replaceall话题: character话题: wrong话题: since