Re: String replaceAll doesn't like commas
- From: Alan Krueger <wgzkid502@xxxxxxxxxxxxxx>
- Date: Tue, 31 Jan 2006 15:38:59 -0600
Jeffrey Schwab wrote:
O.B. wrote:Why doesn't the following turn "Bubba, Inc." into "Bubba\, Inc."?
String test = "Bubba, Inc."; test = test.replaceAll(",", "\\,");
The double quotes eat one backslash. The regex parser eats the other. Try "\\\\,".
It gets really fun when you want to quote backslashes in a string with an additional backslash:
someString.replaceAll("\\\\", "\\\\\\\\");That's a lot of backslashes. .
- References:
- String replaceAll doesn't like commas
- From: O.B.
- Re: String replaceAll doesn't like commas
- From: Jeffrey Schwab
- String replaceAll doesn't like commas
- Prev by Date: Re: javascript:false
- Next by Date: Re: Various Interest Rates
- Previous by thread: Re: String replaceAll doesn't like commas
- Next by thread: Re: String replaceAll doesn't like commas
- Index(es):