toNumericStringByRegex function
String
toNumericStringByRegex(
- String? inputString, {
- bool allowPeriod = false,
- bool allowHyphen = true,
})
Implementation
String toNumericStringByRegex(
String? inputString, {
bool allowPeriod = false,
bool allowHyphen = true,
}) {
if (inputString == null) return '';
var regexWithoutPeriod = allowHyphen ? _digitRegExp : _positiveDigitRegExp;
var regExp = allowPeriod ? _digitWithPeriodRegExp : regexWithoutPeriod;
return inputString.splitMapJoin(
regExp,
onMatch: (m) => m.group(0)!,
onNonMatch: (nm) => '',
);
}