How can I get ['999'] out of this string? '451999277'? I only want repetitions of the same character.
This is what I've tried:
'451999277'.match(/(\d{3})/g) // === ["451", "999", "277"]
'451999277'.match(/(\d){3}/g) // === ["451", "999", "277"]
'451999277'.match(/([0-9]){3}/g) // === ["451", "999", "277"]
'451999277'.match(/(\d)\1{3}/g) // === null
.......
[EDIT]
solution:
'451999277'.match(/(\d)\1{2}/g) // === ['999']
(\d)matches one digit,\1{3}matches three digits, so(\d)\1{3}would require four digits to match.===in the comment. I'd like to point out that even['999'] === ['999']isfalse. We get what you meant though.