I am trying to determine whether a string contains exactly one given distinct character, repeated at least once. For example “bbbbb” should match but “ccMMcc” should not as it contains two different letters, c and m respectively. Presuming regular expressions would be the simplest way to do so, shame I suck at them, what will I need to match my string against?
I am trying to determine whether a string contains exactly one given distinct character,
Share
You can use a backreference: