Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

88
Views
Regular expression to check any character in more than two times

I'm looking for a simple regular expression to match same character in the string more than two times likes following in java script. (Number 1 is three times) 112561

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You could check if a group is more than tow times in the array.

console.log(/(.).*\1.*\1/g.test('12561'));
console.log(/(.).*\1.*\1/g.test('112561'));
console.log(/(.).*\1.*\1/g.test('2125611'));

about 4 years ago · Juan Pablo Isaza Report

0

The following regex can be used for this purpose:

.*(.).*\1.*\1.*
about 4 years ago · Juan Pablo Isaza Report

0

This will check if a character is repeated more than 2 times in a string. Note that this also does not use * which is a cause for performance issues in JavaScript.

console.log(/.+?(.)((?:.)+?\1){1,}/.test('abcZdefZghiZ'))
console.log(/.+?(.)((?:.)+?\1){1,}/.test('112561'))
console.log(/.+?(.)((?:.)+?\1){1,}/.test('12561'))

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!