我已经编写了用于识别float和int的正则表达式,但它们似乎不起作用(下面的代码).
{
string sumstring = "12.098";
Regex flt = new Regex(@" ^[0-9]*(\.[0-9]*)");
Regex ent = new Regex("^[0-9]+");
if (d_type.IsMatch(sumstring))
{
Console.WriteLine(sumstring + " " + "dtype");
}
Match m = ent.Match(sumstring);
if (m.Success)
{
Console.WriteLine("int");
}
else if (flt.IsMatch(sumstring))
{
Console.WriteLine("float");
}
}
Run Code Online (Sandbox Code Playgroud)
哪里出错了?
for(int j = 0; j < arrayList.size(); j++) {
System.out.print(arrayList.get(j));
}
Run Code Online (Sandbox Code Playgroud)
我想以5个为一组进行打印,但代码看起来如何?我是否必须将元素存储到变量中并以这种方式打印?