只是为了澄清(不是作为“答案”,而是因为 cmets 不允许此响应的长度),您打算遇到这些类型的输入吗?是否缺少任何场景?
编辑: 分隔小数,添加一些“无效”情况。
### WITH DECIMALS ###
# No separators, with decimals (using '.')
1.00 10.00 100.00 1000.00 10000.00 100000.00 1000000.00 10000000.00 100000000.00
# No separators, with decimals (using ',')
1,00 10,00 100,00 1000,00 10000,00 100000,00 1000000,00 10000000,00 100000000,00
# Thousand separators (using ','), with decimals (using '.')
1,000.00 10,000.00 100,000.00 1,000,000.00 10,000,000.00 100,000,000.00
# Thousand separators (using '.'), with decimals (using ',')
1.000,00 10.000,00 100.000,00 1.000.000,00 10.000.000,00 100.000.000,00
# Thousand separators (using ' '), with decimals (using ',')
1 000,00 10 000,00 100 000,00 1 000 000,00 10 000 000,00 100 000 000,00
# Thousand separators (using "'"), with decimals (using '.')
1'000.00 10'000.00 100'000.00 1'000'000.00 10'000'000.00 100'000'000.00
# Thousand separators (using "'"), with decimals (using ',')
1'000,00 10'000,00 100'000,00 1'000'000,00 10'000'000,00 100'000'000,00
### WITHOUT DECIMALS ###
# No separators, no decimals
1 10 100 1000 10000 100000 1000000 10000000 100000000
# Thousand separators (using ','), no decimals
1,000 10,000 100,000 1,000,000 10,000,000 100,000,000
# Thousand separators (using '.'), no decimals
1.000 10.000 100.000 1.000.000 10.000.000 100.000.000
# Thousand separators (using ' '), no decimals
1 000 10 000 100 000 1 000 000 10 000 000 100 000 000
# Thousand separators (using "'"), no decimals
1'000 10'000 100'000 1'000'000 10'000'000 100'000'000
### INVALID, reusing separator and decimal indicator ###
1,000,00 10,000,00 100,000,00 1,000,000,00 10,000,000,00 100,000,000,00
1.000.00 10.000.00 100.000.00 1.000.000.00 10.000.000.00 100.000.000.00
### INVALID, non-numeric input or invalid separators ###
11a111.11
1-000 1-000.00 1-000,00 100!000.00