Skip to content

@serenity-is/corelib / parseDecimal

Function: parseDecimal()

parseDecimal(s): number

Defined in: src/base/formatting.ts:592

Parses a string as a decimal number using Culture group and decimal separators.

Parameters

s

string

String to parse; null or whitespace yields null. Group separators are stripped and the locale decimal separator is normalized to "." before parseFloat.

Returns

number

The parsed number, null for empty/null input, or NaN when the string is not a valid decimal.

Remarks

Only patterns matching ^\s*[+-]?(\d*)[decimalSep]?(\d*)\s*$ are accepted.