Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use regular expressions to detect decimals in JavaScript

Shulou Source: shulou.com Published: 2022-06-01 03:00:23 11月17日 Update

Editor to share with you how to use regular expressions to detect decimals in JavaScript, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

With regular expressions, the syntax "var rep=/ [\.] /; rep.test (num)".

Function isDot (num) {var rep=/ [\.] /; if (rep.test (num)) {console.log ("is a decimal");} else {console.log ("not a decimal");}} isDot (121.121); / is a decimal isDot (454.654); / / is a decimal isDot (454654) / / not above the decimal number is all the contents of the article "how to detect decimals using regular expressions in JavaScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Decimal regular expression article test content not much most more knowledge industry grammar information information channel channel reference learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS NVidia OPPO Reno Xiaomi Shulou Tech Info