Re: String replaceAll doesn't like commas
- From: Roedy Green <my_email_is_posted_on_my_website@xxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 04:39:29 GMT
On Mon, 30 Jan 2006 20:53:29 -0600, "O.B." <funkjunk@xxxxxxxxxxxxx>
wrote, quoted or indirectly quoted someone who said :
>>>test = test.replaceAll(",", "\\,");
>>
>>
>> Why not just read about it in the documentation?
>>
>> http://download.java.net/jdk6/docs/api/java/lang/String.html#replaceAll(java.lang.String,%20java.lang.String)
>
>What's wrong with my regular expression?
\\ is a magic character to regexes and in a magic character to Java
string literals. You have to "quote" it for both. The docs are not
clear unless you read up on Matcher.replaceAll, but he second parm is
a regex too, not just a simple string.
See http://mindprod.com/jgloss/regex.html#QUOTING
http://mindprod.com/regex.html#AWKWARD
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
.
- Follow-Ups:
- Re: String replaceAll doesn't like commas
- From: Roedy Green
- Re: String replaceAll doesn't like commas
- References:
- String replaceAll doesn't like commas
- From: O.B.
- Re: String replaceAll doesn't like commas
- From: O.B.
- String replaceAll doesn't like commas
- Prev by Date: Re: Java questions: Urgent
- Next by Date: Re: Java 1.6 Heisenbug involving startsWith
- Previous by thread: Re: String replaceAll doesn't like commas
- Next by thread: Re: String replaceAll doesn't like commas
- Index(es):