Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Checking for repeating characters

Posted on 2006-11-20
3
Medium Priority
?
308 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 64

Accepted Solution

by:
Fernando Soto earned 500 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 64

Expert Comment

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

879 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