decimal string regex code example Example 1: regex validate double with 2 decimals ^(\d+(\.\d{0,2})?|\.?\d{1,2})$ Example 2: /^ 0-9 *$/ decimal /^\d*\.?\d*$/