how can i check for a pattern occuring a certain number of times?
eg:
4444444 => return 4
4444332 => return 4
4444431 => return 4
4443333 => return 0
4243424 => return ?
but if character 4 occurs less than 4 times then return 0
i am just looking for 4 here. if it appears more than or equal to 4 times then value returned would be 4. the other 3 numbers in the string can range from 1 to 3 only.
thank you.
If you need four consecutive 4s, it’s just
4{4}or4444. If they don’t need to be consecutive,4.*4.*4.*4will do it. If it can be any number, but has to be four times, then([1-4])\1{3}or([1-4]).*\1.*\1.*\1depending on whether you need them to be consecutive or not.