using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;namespace ConsoleCSharp
{
class Program
{
static void Main(string[] args)
{
string[] str = { @"判断一段文字中是否包含 ”中国“和 ”欧盟“,这两个关键字不一定 挨着", "问这个正则表达式怎么写????两个关键字同时出现才算匹配成功" };
Regex re = new Regex(@"中国.*?欧盟");
foreach (string s in str)
Console.WriteLine(re.Match(s).Success);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;namespace ConsoleCSharp
{
class Program
{
static void Main(string[] args)
{
string[] str = { @"判断一段文字中是否包含 ”中国“和 ”欧盟“,这两个关键字不一定 挨着", "问这个正则表达式怎么写????两个关键字同时出现才算匹配成功" };
Regex re = new Regex(@"中国.*?欧盟");
foreach (string s in str)
Console.WriteLine(re.Match(s).Success);
}
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货