文章标签 ‘C#’

要查找的内容: <a class=”class1” href=”http://www.radys.cn”>正则一</a> <a href=”http://www.radys.cn” target=”_blank”>正则二a> <a href=”http://www.radys.cn” style=”color:#ff0”>正则三</a> <a href=”http://www.radys.cn” rel=”nofollow”>正则四内容</a> <a title=”内空五” href=”http://www.radys.cn” rel=”nofollow”><img src=”http://www.radys.cn/logo.jpg” alt=”logo”/></a>   正则表达式(C#) <a(.+?)href="([^>]+?)"([^>]*?)>(((?!<img).)*?)</a>

2010年7月28日17:36 | 没有评论
分类: 后端

IEnumerable<string> strings = …; // C# 3 and .NET 3.5:string joined = string.Join(",", strings.ToArray());// C# 2 and .NET 2.0:string joined = string.Join(",", new List<string>(strings).ToArray()); 基本思路先转为Array,然后使用string.Join()解决问题.

2009年11月9日23:38 | 没有评论
分类: 后端
标签: ,

   我们判断一个字符串是不是“数字,”格式     C#         /// <summary>         ///  判断字符是否由数字+,格式组成         /// </summary>         /// <param name="input">字符输入</param>         /// <returns>如果是数字+,格式的返回真,否则返回假</returns>         public bool IsFormat(string input)         {             if (Regex.IsMatch(input, "^[\\d,]+$"))             {                 return true;             }             return false;         }    使用 bool result = IsFormate(checkstring);

2009年6月19日13:52 | 没有评论
分类: 前端页面
标签: ,

引用命名空间 using System.IO; 方法: private static void CreateFolder(string folder)         {             if (Directory.Exists(folder))             {                 Console.Write("ok");             }             else             {                 Directory.CreateDirectory(folder);             }         } static void Main(string[] args) {             string folder = "E:\\images\\2009";             CreateFolder(folder ); } 这样可以创建指定的文件夹。

2009年5月20日22:16 | 没有评论
分类: 后端
标签:

  C#中正则里 .* 匹配除换行之外的任意内容   用[\s\S]+ 匹配包括换行符在内的任意内容   如下面的内容   <div>   <p>test</p><b>正则匹配任意内容111111</b> 这里的也有内容   </div> <div>   <p>test</p><b>正则匹配任意内容22222222</b> 这里的也有内容   </div> <div>   <p>test</p><b>正则匹配任意内容33333333</b> 这里的也有内容   </div> 用取出div内容 用<div>(?<content>[\s\S]+)</div>作为正则匹配 Regex r = new Regex(regexString, RegexOptions.IgnoreCase | RegexOptions.Compiled); MatchCollection mc = r.Matches(content); mc的count为1,如果使用非贪婪匹配也就是正则表达式为 <div>(?<content>[\s\S]+?)</div> 则mc的count为3 任意内容的匹配就是这样来做的。

2009年5月19日00:08 | 没有评论
分类: 后端

使用C#操作删除文件夹函数         private void DeletePath(System.IO.DirectoryInfo path)         {             foreach (System.IO.DirectoryInfo d in path.GetDirectories())             {                 DeletePath(d);                 d.Delete();             }             foreach (System.IO.FileInfo f in path.GetFiles())             {                 f.Delete();             }           } 使用方法 System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(“E:\\test\\”); DeletePath(di); 如果你只想删除其中的文件保留其中的文件夹结构可把 d.Delete();注释//d.Delete(); 你可能对以下内容也感兴趣:    jquery分页插件,ajax中不可少的小东西 jQuery插件,N多可用插件收集备用(转帖) jquery validator errorPlacement demo JQuery中is的使用

2009年4月11日10:40 | 没有评论
分类: 后端
标签: ,

这两天整理一下磁盘空间,发现几本曾了好久的电子书,比如<人月神话>,还有<C#语言参与手册> 下面是下载地址: 人月神话中文版 http://www.box.net/shared/ypy7nre4rr C#语言参考.pdf http://www.box.net/shared/2lf6nak9m8 ASP.NET.pdf http://www.box.net/shared/y9lveynayr

2009年3月16日01:04 | 没有评论
分类: 后端
标签:

     现象:ASP.NET后台写入中文COOKIE后,前台用JS读取为乱码     解决:     后台ASP.NET写入     HttpContext.Current.Request.Cookies[“cookiename”].Value = System.Web.HttpUtility.UrlEncode(strValue,Encoding.UTF8);     前台JS读取     使用decodeURIComponent解码显示 你可能对以下内容也感兴趣.Net List&lt;obj&gt;序列化和反序列化asp.net(C#)删除夹中所有文件和文件夹Asp.net中给DataTable排序(sort DataTable)

2008年11月21日12:46 | 1 条评论
分类: 后端
标签: ,

      先查询递归查询所有TextBox控件,然后加上onfocus和onblur属性。      具体代码如下:      /// <summary>      /// 为所有的TextBox添加高亮特效,当然如果你想把所有的input都加上的话,只要更改条件就可以了      /// </summary>      public static void SetInputControlsHighlight(Control container, string className)      {         foreach (Control ctl in container.Controls)         {            if (ctl is TextBox)//这里是条件            {               WebControl wctl = ctl as WebControl;               wctl.Attributes.Add("onfocus", string.Format("this.className = ‘{0}’;", className));               wctl.Attributes.Add("onblur", "this.className = ”;");            }            else            {               if (ctl.Controls.Count > 0)                  SetInputControlsHighlight(ctl, className);            }         }      } [...]

2008年8月6日23:13 | 没有评论
分类: 后端
标签:

     Q:HTTP 状态代码,你知道吗?     A:以下内容来自GOOGLE,备忘     HTTP 状态代码表示什么意思? 如果某项请求发送到您的服务器要求显示您网站上的某个网页(例如,用户通过浏览器访问您的网页或 Googlebot 抓取网页时),服务器将会返回 HTTP 状态码响应请求。 此状态代码提供关于请求状态的信息, 告诉 Googlebot 关于您的网站和请求的网页的信息。 一些常见的状态代码为: 200 – 服务器成功返回网页 404 – 请求的网页不存在 503 – 服务器暂时不可用 下面提供 HTTP 状态代码的完整列表。 点击链接可了解详情。 您也可以访问 HTTP 状态代码上的 W3C 页获取更多信息。 1xx(临时响应) 表示临时响应并需要请求者继续执行操作的状态代码。 100(继续) 请求者应当继续提出请求。 服务器返回此代码表示已收到请求的第一部分,正在等待其余部分。 101(切换协议) 请求者已要求服务器切换协议,服务器已确认并准备切换。 2xx (成功) 表示成功处理了请求的状态代码。 200(成功) 服务器已成功处理了请求。 通常,这表示服务器提供了请求的网页。 如果针对您的 robots.txt 文件显示此状态代码,则表示 Googlebot 已成功检索到该文件。 201(已创建) 请求成功并且服务器创建了新的资源。 202(已接受) [...]

2008年8月4日23:44 | 没有评论
分类: 前端页面
标签: