string RegexString = "<title>.+?</title>";
string pageStr = "2323232323<title>Salyani Technologies (P) Ltd.</title>23232323232";
string resString = "";
Regex reg = new Regex(RegexString, RegexOptions.IgnoreCase);
MatchCollection matches = reg.Matches(pageStr);
foreach (Match match in matches)
{
resString += match.Groups[1].Value;
}
Response.Write(resString+"/Test");
string pageStr = "2323232323<title>Salyani Technologies (P) Ltd.</title>23232323232";
string resString = "";
Regex reg = new Regex(RegexString, RegexOptions.IgnoreCase);
MatchCollection matches = reg.Matches(pageStr);
foreach (Match match in matches)
{
resString += match.Groups[1].Value;
}
Response.Write(resString+"/Test");
=>
RegexString = "<title>(.+?)</title>";
string RegexString = ".*?<title>(.+?)</title>.*?";
string pageStr = "2323232323<title>Salyani Technologies (P) Ltd.</title>23232323232";
string resString = "";
Regex reg = new Regex(RegexString, RegexOptions.IgnoreCase);
MatchCollection matches = reg.Matches(pageStr);
foreach (Match match in matches)
{
resString += match.Groups[1].Value;
}
string pageStr = "2323232323<title>Salyani Technologies (P) Ltd.</title>23232323232";
string resString = "";
Regex reg = new Regex(RegexString, RegexOptions.IgnoreCase);
MatchCollection matches = reg.Matches(pageStr);
foreach (Match match in matches)
{
resString += match.Groups[1].Value;
}
Response.Write(resString+"/Test");另一种这样 string RegexString = "(?<=<title>).+?(?=</title>)";
string pageStr = "2323232323<title>Salyani Technologies (P) Ltd.</title>23232323232";
string resString = "";
Regex reg = new Regex(RegexString, RegexOptions.IgnoreCase);
MatchCollection matches = reg.Matches(pageStr);
foreach (Match match in matches)
{
resString += match.Value;
}
Response.Write(resString+"/Test");以上两种都行,取出的值是Salyani Technologies (P) Ltd.