Solved

Checking for repeating characters

Posted on 2006-11-20
3
277 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
Comment Utility
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
Comment Utility
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
Comment Utility
Glad I was able to help. Have a great day. ;=)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

12 Experts available now in Live!

Get 1:1 Help Now