9

Validation of the telephone number not having all the digits repeated

 2 years ago
source link: https://www.codesd.com/item/validation-of-the-telephone-number-not-having-all-the-digits-repeated.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Validation of the telephone number not having all the digits repeated

advertisements

I want to validate a telephone number of foramt (xxx) xxx-xxxx. This number should not contain all repeating digits. i.e, I have to validate if the user enters a number like (999) 999-9999. But should allow any other format. How to write a regular expression for this.

Please help.

Thanks, Siri


To validate a North American style phone number you could use:

\(?\d{3}\)?[- ]?\d{3}-?\d{4}

This allows the repeating digits. To filter those out, you could run a second regex that uses backreferences to validate all the following digits match the first digit match. Here is a regex with phone formatting optional:

\(?(\d)\1\1\)?[- ]?\1{3}-?\1{4}

Tags regex

Related Articles

Validation of international telephone number

I need to do pretty basic phone-number validation and formatting on all US and international phone numbers in Python. Here's what I have so far: import re def validate(number): number = re.compile(r'[^0-9]').sub('', number) if len(number) == 10: # te

the smallest non-negative number not in a list of repeatable numbers

This is a variation of [1]. I have a list of N (number of values N is known) non-negative integers. Upper bound of the list is 1024. What is the smallest non-negative integer not in the list? For ex., the list could be 0,3,6,2,4,1,8,0,9,0 - then the

Navigation, exchange of funds not having all bed; li & gt; on mouseover

I am using the following jquery code: $("#top ul li.corner").mouseover(function(){ $("span.left-corner").addClass("left-corner-hover"); $("span.right-corner").addClass("right-corner-hover"); $("span.c

Validation of the digital input when formatting the digital input

In an asp.net-mvc project using C#. I use a function to format larger numbers with commas such as 1,000,000, thanks to this post: function numberWithCommas(str) { return str.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); } The issue is, I hav

How to validate the format of the telephone number

i am about to create a validation for phone number format..The format is 10 digit including the plus sign eg:+0133999504. Even though I have declare the pattern which is I try to disallow the "-" symbol or any other characters, but the validatio

Validation of the 7-digit telephone number

What I'm trying to accomplish is the following... Asks user for number and check to see if number provided by user input is a 7 digit integer. If it's a string, throw InputMismatchException and ask again for the number. Is there an easy way to accomp

The validator of the credit card number does not work properly

def checksum(card_without_check): card_without_check = card_without_check[-1::-1] def numbers(string): return [int(x) for x in string] print(card_without_check) odd_numbers = numbers(card_without_check[0::2]) even_numbers = numbers(card_without_check

Validation of the phone number using JavaScript with .NET?

How do I validate phone numbers using JavaScript in ASP.NET?Validating telephone numbers is a difficult problem. Essentially, you define a regular expression that match the pattern(s) for a valid phone number. The conventions for a phone number are h

Validation of the java phone number

Here is my problem: Create a constructor for a telephone number given a string in the form xxx-xxx-xxxx or xxx-xxxx for a local number. Throw an exception if the format is not valid. So I was thinking to validate it using a regular expression, but I

What is the point of MVC implementation of IValidatableObject if it can not be used to perform a complete validation of the object?

Please can someone help me, because I'm having real trouble getting on with validating my objects that have bound in my controller actions in one swoop. I thought that IValidatableObjects Validate() method would fire every time the binding takes plac

Validation of the template form does not work and hellip; I do not understand why

model.py from django.core.exceptions import ValidationError def surname_validate(value): if value == "123": raise ValidationError('is not an even number') class Member(models.Model): surname=models.CharField(max_length=50,validators=[surname_val

Algorithm to find the number of numbers between 2 integers where the digits do not repeat

I'm looking for an algorithm to find a list of numbers between two integers such that the digits in each number don't repeat? For example, given an input of 2 and 12, the answer would be all numbers except 11. The naive solution would be to iterate o

FindFirstFile / FindNextFile does not return all files in the folder

Note: The question suggested as a duplicate discusses CreateFile, ERROR_FILE_NOT_FOUND, having existing handles on a file, and flagging a file to be deleted later. While it is a similar topic, none of those issues relate to my case. I have the follow

How do I add values ​​from the text field when I press the button without having all the values

im working on a java program using GUI, and i ran into a problem whenever i try to add the values from the text fields and one is missing it doesn't work and i get an error but if all of them are available i get the right answer, how can i add withou

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK