How to check if all the charactersof a string are same?

Hello,

There is a string like the following example:

|AAAAA |TRUE|
|AAC |FALSE|
|CCCCCCC |TRUE|

How to check if all the charactersof a string are same?THX~

@Bosch

Please try as below using outmatches.

1 Like

Hi,

Can you try the following condition?

yourString.Distinct().Count()=1

Regards,

2 Likes

It’s amazing!Thanks for your help!

1 Like

It’s profound~I will try my best to learn!THX~

Can i ask one more question?

IF the unique value in the string=A

There is a string like the following example:

|AAAAA |TRUE|
|AAC |FALSE|
|CCCCCCC |FALSE|

How to check string in this condition?THX…

Hi,

How about the following?

System.Text.RegularExpressions.Regex.IsMatch(yourString,"[^A]")

Regards,

2 Likes

It’s worked!!!I’ve thought about it for a long time…THX

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.