Regular expressions for validating currency

Embedded as I am in globalizing applications I thought I would create this entry for future reference.

More than once I have to validate user input and more than once that input is a currency value. The currency symbols are not part of the expressions here.

For en-US or en-CA:

^(\d{1,3})(,\d{3})*(\.\d{2})?$

fr-CA currency formatting regular expression:

^(\d{1,3})(\s{1}\d{3})*(,\d{2})?$

Ttyl!

2 thoughts on “Regular expressions for validating currency”

  1. Hi,

    Found this post while searching for a currency regex to help with my cms project – and your’s works instantly! Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.