Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我有这个-
lr_min = $('#lr_min').val().replace(/\D/g,'');
它消除了字符串中的所有非数字字符。如何从此替换中排除句点 (.)?
您可以使用
lr_min = $('#lr_min').val().replace(/[^\d.]+/g,'');
+不是绝对必要的,但通常会提供更好的性能(更少的替换)
+
您可以忽略数字之间的点。
lr_min = $('#lr_min').val().replace(/[^\d.-]/g, '');