Kaif
Kaif

Reputation: 131

Regular expression to find a match for repeated pattern

I am trying to write a reg expression to find match of 5 different character repeated 3-5 times. e.g: I have 4 nos and 1 char like 1,2,3,4,a. and i just want to check whether one of these digit/char is present in a string in repeated pattern for 3-5 times. like "22299" should return true because "222" is present here for 3 times. if string is like this "22300" it should return false because "223" is not a pattern.If it was like this "22333" then should return true.

i tried [1234a]{3,5} but its returning true for "22300" pattern and also tried this (1|2|3|4|a){3,5} but same result.

Upvotes: 0

Views: 55

Answers (1)

JonM
JonM

Reputation: 1374

try this expression:

([1234a])\1{2,4}   

Upvotes: 1

Related Questions