Regular Expression Help

rurpy at yahoo.com rurpy at yahoo.com
Sun Apr 12 00:19:06 EDT 2009


On Apr 11, 9:42 pm, Jean-Claude Neveu <jcn-france1... at pobox.com>
wrote:

> My regexp that I'm matching against is: "^\$\£?\d{0,10}(\.\d{2})?$"
>
> Here's how I think it should work (but clearly
> I'm wrong, because it does not actually work):
>
> ^\$\£?      Require zero or one instance of $ or £ at the start of the string.

The "or" in "$ or £" above is a vertical bar.  You
want ^(\$|£)? here.

> d{0,10}     Next, require between zero and ten alpha characters.
> (\.\d{2})?  Optionally, two characters can
> follow. They must be preceded by a decimal point.



More information about the Python-list mailing list