去掉HTML字符:System.Text.RegularExpressions.Regex.Replace(HTMLStr, "<[^>]*>", "");
o.innerHTML=o.innerHTML.replace(/(<\/?(?!br|p|img)[^>\/]*)\/?>/gi,'');
o.innerHTML=o.innerHTML.replace(/(<\/?(?!img)[^>\/]*)\/?>/gi,'');
if(e.width > 180 || e.height > 240)
{
e.height = Math.floor(e.height * 180 / e.width);
e.width = 180;
}
匹配一个图片:<img.+?>
匹配多个图片:<img.*>
匹配一个src:@"src\=['|""]?(\w|[\u4e00-\u9fa5]|\\|\/)+\.(JPG|BMP|GIF|jpg|bmp|gif){1}['|""]?"
/<IMG.src=.*>/这个可以匹配一个图片
下面匹配多个图片:图片正则:/<IMG.src=.*?>/ 非贪婪模式
或者
/<IMG.src=[^>]*>/
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
string fn = File1.PostedFile.FileName;
FileStream fs = new FileStream(fn,FileMode.Open,FileAccess.Read);
StreamReader sr = new StreamReader(fs);
string s = sr.ReadToEnd();
ArrayList al = new ArrayList();
Regex r = new Regex(@"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
MatchCollection m = r.Matches(s,0);
foreach(Match mh in m)
{
al.Add(mh.Value);
}
if (al.Count > 0)
{
ListBox1.DataSource = al;
ListBox1.DataBind();
return;
}
// Label1.Text = "<al中\n没有值!";
DIV1.InnerText = "al\r中\n没有<br>值!";