Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use js regular expressions to separate numbers with spaces every four digits

Shulou Source: shulou.com Published: 2022-06-02 05:10:05 11月15日 Update

This article is about how js regular expressions enable numbers to be separated by spaces every four digits. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Code examples are separated by spaces every four digits of the number:

Share a code example that enables numbers to be separated by spaces every four digits.

This effect is very common when filling out bank cards, which is also a very humane measure.

The code example is as follows:

$(document) .ready (function () {$('# ant'). On ('keyup mouseout input', function () {var $this = $(this); var v = $this.val (); /\ s {5} / .test (v) & & $this.val (v.replace (/\ sCPG,'). Replace (/ (. {4}) / g, "$1");}) Thank you for reading! This is the end of the article on "how js regular expressions separate numbers with spaces every four digits". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Code numbers spaces examples regular expressions content more articles good practical actions human nature common effects articles times right and wrong see knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MySQL Shulou Technology macOS Xiaomi