| Author |
Replacing Characters
|
Steve Dyke
Ranch Hand
Joined: Nov 16, 2004
Posts: 1254
|
|
Why won't this strip out the '$''s getplarray[i].replaceAll("$","") [ February 13, 2008: Message edited by: Steve Dyke ]
|
 |
marc weber
Sheriff
Joined: Aug 31, 2004
Posts: 11343
|
|
(I'm assuming you're working with a String.) Notice in the API that replaceAll treats the first String argument as a Regular Expression. In that context, the '$' character has special meaning to represent the end of a line. So if you want a literal '$' in your pattern, you need to use an escape sequence of \$. And in the context of a String literal, this needs an additional backslash to avoid interpretation as a Unicode escape or character escape -- that is, \\$.
|
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
|
 |
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
|
|
|
Or, ever since JDK 1.5 you can use the replace() method rather than replaceAll(). Despite its name, the real difference is that replace() doesn't treat the first argument as a regular expression. So it's simpler, but less powerful.
|
"I'm not back." - Bill Harding, Twister
|
 |
 |
|
|
subject: Replacing Characters
|
|
|