Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
Script is used to check if the number has 10 digts( you can update the digit count in the code based on the need.
# Digit Length Validator

## Description

This script checks if a string contains exactly a specified number of digits. Useful for validating numeric input. The digit count can be adjusted in the code.

## Usage
To change the required digit count, update the number in the regular expression
```
var digitLengthRegex = /^\d{N}$/; // Replace N with desired digit count
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var reg = '/^\d{10}$/'; // Update the number based on the need
var digitLengthRegex = /^\d{10}$/; // Matches exactly 10 digits

var k = '123456789144'; // example
var elevenString = '01234567899'; // 11 digits
var tenString = '0123456789'; // 10 digits
var nineString = '012345678'; // 9 digits

if (/^\d{10}$/.test(k)){ // This will check if it has 10 digits
}
gs.info(digitLengthRegex.test(elevenString)); // false
gs.info(digitLengthRegex.test(tenString)); // true
gs.info(digitLengthRegex.test(nineString)); // false
Loading