语文不过关啊
i不等于1或者2 在否定句里面,或者不是选择而是并列啊
也就是说,i不等于1或者2是i即不能等于1也不能等于2
所以表达是是i!=1 && i!=2
换句话说 i!=1||i!=2这样的表达式有意义吗? 明显是永远成立的,因为i不可能同时为1和2,所以i!=1 和i!=2至少有一个为真,在||相连接的情况下 这个表达式恒为1 啊
个人认为本人正解 楼主如何采纳我就不管啦 :D
你要获取begin到over中间的一段,可以用正则表达式:begin()over
如果你要一定写不等于over的正则表达式,可以用正则表达式:begin(((!over)))over
完整的C#语言例子程序如下:
using System;using SystemCollectionsGeneric;
using SystemText;
using SystemTextRegularExpressions;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string s = "begin 这是一个XXXXX over begin 这是一个MMMMMMMover";
Regex r = new Regex("begin(((!over)))over");
MatchCollection matches = rMatches(s);
for (int i = 0; i < matchesCount; i++)
{
if (matches[i]Success)
{
ConsoleWriteLine(matches[i]Groups[1]Value);
}
}
ConsoleReadKey();
}
}
}
运行结果:
这是一个XXXXX
这是一个MMMMMMM
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)