Skip to content

Instantly share code, notes, and snippets.

@MarkMYoung
Created September 26, 2019 16:40
Show Gist options
  • Save MarkMYoung/8b836302af671b17a4c51a5d3e865685 to your computer and use it in GitHub Desktop.
Save MarkMYoung/8b836302af671b17a4c51a5d3e865685 to your computer and use it in GitHub Desktop.
Regular Expression Toolbox: Monetary Number Pattern (Up to 2 Decimal Places)
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
let RegExpToolbox =
{
// This regular expression which matches only numbers with up to two decimal
// places, and allowing a preceding decimal (without a zero)
// but not a trailing decimal.
monetaryNumberRegExp:new RegExp( "^(\\d+(?:[\\.]\\d{1,2})?|(?:\\d+)?(?:[\\.]\\d{1,2}))$" ),
}
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment