I am trying to remove the dollar format from the string \'$1,109,889.23\'. I tried using a regular expression with:
\"[^\\\\d]\"
but then I ge
How about just doing a search and replace for ,
and $
?
but if you're going to do it.
[^\d.]+
Would this RegEx work for you?
^\$
In Java:
String newString = oldString.replaceAll("$", "");
I am using ColdFusion. The [^\d.] works great as eldarerathis mentioned above.
<cfset amt = '$1,109,889.23'>
<cfset newAmt = ReReplace(amt, "[^\d.]", "","ALL") >
<cfoutput>#newAmt#</cfoutput>
[\d,.]+
would give you the number part. Here is your example on Rubular.
Since $
is a metacharacter in regex (it means "end of string" or "end of line", depending on the current settings), it needs to be escaped to \$
. But why use a regex at all if it's just one fixed character?