accounting-js - v2.0.3
    Preparing search index...

    Function unformat

    • Takes a string/array of strings, removes all formatting/cruft and returns the raw float value.

      Decimal must be included in the regular expression to match floats (defaults to settings.decimal), so if the number uses a non-standard decimal separator, provide it as the second argument.

      Also matches bracketed negatives (eg. '$ (1.99)' => -1.99).

      Doesn't throw any errors (NaNs become 0 or provided by fallback value).

      Usage:

      unformat('£ 12,345,678.90 GBP');
      // => 12345678.9

      Parameters

      • value: string

        String containing the number to parse

      • Optionaldecimal: string = ...

        The character used to represent the decimal separator

      • Optionalfallback: number = ...

        Value returned on unformat() failure

      Returns number

      • Parsed number