Solved

Checking for repeating characters

Posted on 2006-11-20
3
280 Views
Last Modified: 2010-04-16
I am implementing quite strict username policies. I have managed to implement 90% of all the validators (such as "must contain at least one uppercase letter, at least one numeric character, no special characters etc). The username string can't contain more than 4 repeating characters, e.g. Bob123aaaaa. I have looked for regex to check for this, but I wasn't succesful. Any help?
0
Comment
Question by:Caroline_Swart
  • 2
3 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 125 total points
ID: 17979981
Hi Caroline_Swart;

The following Regex pattern will detect 5 or more repeating characters.

        string pattern = @"(?<1>.)\k<1>{4,}";

Fernando
0
 

Author Comment

by:Caroline_Swart
ID: 17980449
Thank you very much, it worked first time and I didn't need to change a thing. Your help is appreciated.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 17980487
Glad I was able to help. Have a great day. ;=)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ConsoleSql 1 34
Events in static methods 3 50
Error on Add method 1 38
Filename to be appended with DateTimeof Download 3 46
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now