How to determine if all characters in a string are equal

后端 未结 6 1064
甜味超标
甜味超标 2021-01-13 12:09

I need to know if all characters in a string are equal (formed by the same character). the function must return true or false depending if all the elements of the string ar

6条回答
  •  温柔的废话
    2021-01-13 12:23

    Maybe use StringOfChar to generate a string with the target char repeated N times, then do a string comparison instead of comparing char-by-char.

    (Don't know if this is actually faster; measure & see).

提交回复
热议问题