| Author |
Regular expression
|
Adrian Enns
Ranch Hand
Joined: Aug 11, 2004
Posts: 48
|
|
|
I have a String variable that contains a bunch of $ symbols in it. I want to replace all of the "$" with blank text. I have tried String.replaceAll("$","") but it doesn't work.... does anybody know the regular expression that represents the $ sign?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
|
Try "\\$"
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Adrian Enns
Ranch Hand
Joined: Aug 11, 2004
Posts: 48
|
|
|
Thanks, I figured it out... it's "[$]".
|
 |
Srinivas Redd
Greenhorn
Joined: Mar 23, 2006
Posts: 17
|
|
|
Why "$" doesn't work ... ??? Why we have to give "[$]" ???
|
Srinvasa Reddy Thamma,<br />Chennai,India.
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
Originally posted by Srinivas Redd: Why "$" doesn't work ... ??? Why we have to give "[$]" ???
The reason "$" does not work is because it has special meaning in a regular expression. It means the end of the line -- a marker for a carriage return and/or line feed. BTW, "\\$" or "[$]" should both work. Henry [ April 06, 2006: Message edited by: Henry Wong ]
|
 |
 |
|
|
subject: Regular expression
|
|
|