NumParsingTextX extension

Extension methods for parsing numeric strings with lenient formatting.

These methods strip common grouping characters (commas, spaces, underscores, non-breaking spaces) before parsing. Accounting-style negatives like (123) are converted to -123.

Used internally by Convert.toInt, Convert.toDouble, etc.

on

Methods

toDouble() double

Available on String, provided by the NumParsingTextX extension

Parses this string as a double.
toDoubleFormatted(String format, String? locale) double

Available on String, provided by the NumParsingTextX extension

Parses a formatted double using NumberFormat.
toInt() int

Available on String, provided by the NumParsingTextX extension

Parses this string as an integer, truncating any fractional component.
toIntFormatted(String format, String? locale) int

Available on String, provided by the NumParsingTextX extension

Parses a formatted integer using NumberFormat.
toNum() num

Available on String, provided by the NumParsingTextX extension

Parses this string into a num after stripping grouping characters.
toNumFormatted(String format, String? locale) num

Available on String, provided by the NumParsingTextX extension

Parses this string using a NumberFormat pattern.
tryToDouble() double?

Available on String, provided by the NumParsingTextX extension

Attempts toDouble, returning null on failure.
tryToDoubleFormatted(String format, String? locale) double?

Available on String, provided by the NumParsingTextX extension

Attempts toDoubleFormatted, returning null on failure.
tryToInt() int?

Available on String, provided by the NumParsingTextX extension

Attempts toInt, returning null on failure.
tryToIntFormatted(String format, String? locale) int?

Available on String, provided by the NumParsingTextX extension

Attempts toIntFormatted, returning null on failure.
tryToNum() num?

Available on String, provided by the NumParsingTextX extension

Attempts toNum, returning null when parsing fails.
tryToNumFormatted(String format, String? locale) num?

Available on String, provided by the NumParsingTextX extension

Attempts toNumFormatted, returning null on failure.