using regex to remove $ sign

Fredrik Lundh fredrik at pythonware.com
Tue Apr 11 04:04:47 EDT 2006


"Kun" <neurogasm at gmail.com> wrote:

> i have an html/cgi input that takes in values to a mysql database,
> however, if i stick in $20 instead of 20, it crashes the program
> because of the extra $ sign.  I was wondering if anyone has a quick
> regular expression in python to remove the $-sign if it is present in
> the input.

RE?  ex-perler?  try strip+lstrip instead:

>>> text = "  $12921  "
>>> text.strip().lstrip("$")
"12921"

</F>






More information about the Python-list mailing list