[thelist] pattern match three or more of the same character repeated in a row

cspruck at mindspring.com cspruck at mindspring.com
Wed Jun 12 18:55:01 CDT 2002


On Wed, 12 Jun 2002 13:59:54 -0700 (PDT) Julie O'Neil <julievoneil at yahoo.com> wrote:

I need to match if a given string contains three or more of the same character repeated in a row.
------------------------------------------------

Julie,

Something along the lines of this should work for you:

[a-zA-Z0-9]{3,}

[a-zA-Z0-9] translates as any single upper or lower case letter or a digit and {3,} means at least 3 instances of the preceding group. Something like {3,5} would mean at least 3 and no more than 5.

If you have a specific string you're looking for, just substitute it for [a-zA-Z0-9] and put it in parentheses, followed by the {3,}.

If you still have problems, let me know what you're using a regex within, like Perl, PHP, etc. and more detail about the kind of string or characters you're trying to match.

Let me know if I can help you further! Hope you found my article useful.

Chris



More information about the thelist mailing list