请教:有一个字符串包含"<photo>abcde</photo>",不管"<photo></photo>"里面是什么,我都想把它替换成“”,也就是空。在C#里应当怎么写呢?
我只知道
using System.Text.RegularExpressions;
public static string Replace(string input, string pattern, string replacement);
但是不知道正则表达式怎么写?
你直接设置变量值为
"<photo></photo>"
不就行了,替换来干嘛。。
我需要把xml字符串转换成DataSet存储到数据库中。现在别的都没问题了,就是需要实现不存储照片,所以在xml中去掉字段。不知道用正则表达式怎么替换。
str=Regex.Replace(str,"(?is)<photo>.*?</photo>","");