Finding consecutively repeating characters

Posted on 2011-10-14
Last Modified: 2012-05-12
I'm trying to find a regular expression that will find consecutively repeating characters of 3 or more.

example:  If the string is B000B it should find 000 but if the string is B0000B it should find the first 3 0's from B000 and the last 3 0's from 000B.
Question by:NevSoFly
    LVL 16

    Expert Comment

    by:Easwaran Paramasivam
    LVL 30

    Accepted Solution

    The pattern is


    since the first character is captured by \1 and the other 2 by {2}


    Author Comment

    thanks for your reply.

    The final pattern was actually (.)\1{2,}.  Thanks for the help.

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
    Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

    745 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

    19 Experts available now in Live!

    Get 1:1 Help Now