110,536
社区成员
发帖
与我相关
我的任务
分享
bool flag = true;
if (yourStr.Length == 0)
{
richTextBox2.Text = "空字符串";
}
else
{
char firstChar = yourStr[0];
foreach (char c in yourStr)
{
if (firstChar != c)
{
flag = false;
break;
}
}
}
if (flag)
{
richTextBox2.Text = "全一样";
}
else
{
richTextBox2.Text = "不全一样";
}
public static bool Check_Str(string str)
{
for(int i=0;i<str.length;i++)
{
if(str[i]!=str[0])
return false;
}
return true;
}
Regex reg=new Regex(@"^(.)\1+$");
if(reg.IsMatch("aaaaaaaa"))//匹配
import java.util.regex.*;
public class MyRegex {
public static void main(String[] args) {
String s="1111111111111111";
String temp=s.substring(0, 1);//取第一个字符
int count=0;
Matcher m=Pattern.compile(temp).matcher(s);
while(m.find())
{
count++;
}
if(count==s.length())
System.out.println("全部一样");
else
System.out.println("不一样");
}
}