using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Globalization; using System.IO; using System.Text.RegularExpressions;namespace ConsoleApplication2 { class Program { static void Main(string[] args) { string str2 = ".aspx?id=DZ107-20110609-46902582"; string str3="<LookFor>~/.shtml</LookFor>"; Regex reg2 = new Regex(@"(?i)(?<=.aspx\?).*"); Regex reg3 = new Regex(@"~/"); str2 = "dd/" + reg2.Matches(str2)[0].Value; Console.WriteLine(reg3.Replace(str3,str2)); //<LookFor>dd/DZ107-20110609-46902582.shtml</LookFor> } } } 坐等高人出现。
dd/(\w+-\d+-\d+).shtml? 这样 ?
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string str2 = ".aspx?id=DZ107-20110609-46902582";
string str3="<LookFor>~/.shtml</LookFor>";
Regex reg2 = new Regex(@"(?i)(?<=.aspx\?).*");
Regex reg3 = new Regex(@"~/");
str2 = "dd/" + reg2.Matches(str2)[0].Value;
Console.WriteLine(reg3.Replace(str3,str2));
//<LookFor>dd/DZ107-20110609-46902582.shtml</LookFor>
}
}
}
坐等高人出现。