Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8735321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:01:38+00:00 2026-06-13T10:01:38+00:00

Hi I am trying to use regEx in JS for identifying 3 identical consecutive

  • 0

Hi I am trying to use regEx in JS for identifying 3 identical consecutive characters (could be alphabets,numbers and also all non alpha numeric characters)

This identifies 3 identical consecutive alphabets and numbers : ‘(([0-9a-zA-Z])\1\1)’
This identifies 3 identical consecutive non alphanumerics : ‘(([^0-9a-zA-Z])\1\1)’

I am trying to combine both, like this : ‘(([0-9a-zA-Z])\1\1)|(([^0-9a-zA-Z])\1\1)’

But I am doing something wrong and its not working..(returns true for ’88aa3BBdd99@@’)

Edit : And to find NO 3 identical characters, this seems to be wrong /(^([0-9a-zA-Z]|[^0-9a-zA-Z])\1\1)/ –> RegEx in JS to find No 3 Identical consecutive characters

thanks
Nohsib

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:01:39+00:00Added an answer on June 13, 2026 at 10:01 am

    The problem is that backreferences are counted from left to right throughout the whole regex. So if you combine them your numbers change:

    (([0-9a-zA-Z])\2\2)|(([^0-9a-zA-Z])\4\4)
    

    You could also remove the outer parens:

    ([0-9a-zA-Z])\1\1|([^0-9a-zA-Z])\2\2
    

    Or you could just capture the alternatives in one set of parens together and append one back-reference to the end:

    ([0-9a-zA-Z]|[^0-9a-zA-Z])\1\1
    

    But since your character classes match all characters anyway you can have that like this as well:

    ([\s\S])\1\1
    

    And if you activate the DOTALL or SINGLELINE option, you can use a . instead:

    (.)\1\1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use regex.replace to strip out unwanted characters, but I need
I'm trying to use RegEx to select all strings between two dollar signs. text
I'm trying to use regex to replace source attribute (could be image or any
I am trying to use RegEx to find all cells in OO-calc with :
I am trying to use regex to capture all the <div> and <span> tags
I am trying to use the Regex.Match method to find matching characters in a
trying to use regex to replace any white space with &nbsp;, inside of example
I am trying to use regex generators to create an expression, but I can't
I'm trying to use regex to check if a full address string contains a
I'm trying to use regex to match a string that starts with a <p>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.