简单判断某字符是否在html标签中
2015-09-07 17:50
411 查看
/// <summary> /// 判断某个字符是否在html 属性里面 /// </summary> /// <param name="content"></param> /// <param name="index"></param> /// <returns></returns> private static bool IsInHtmlAttribute(string content, int index) { bool result = false; bool pre=false,post=false; int preIndex = index, postIndex = index; while (preIndex >= 0 && (content[preIndex] != '\'' && content[preIndex] != '"')) { preIndex--; } if (preIndex > 0) { //不是结束属性符号 if (content[preIndex + 1] != ' ' && content[preIndex -1]=='=') { pre = true; } } while (postIndex < content.Length && (content[postIndex] != '\'' && content[postIndex] != '"')) { postIndex++; } if (postIndex < content.Length) { if ((content[postIndex + 1] == ' ' || (content[postIndex + 1] == '/' && content[postIndex + 2] == '>')) && content[postIndex -1] != '=') { post = true; } } if(pre &&post) { result=true; } return result; }
相关文章推荐
- HTML图片拉伸
- MVC Html.AntiForgeryToken() 防止CSRF攻击
- html解析器 HtmlAgilityPack
- HTML相对路径和绝对路径
- Week1----9月8日 HTML基础
- html笔记
- 如何设置HTML页面自适应宽度的table(表格)
- HTML学习-网页主体标记body(三)
- html 表格小demo 1
- html 表格小demo
- HTML学习-网页主体标记body(二)
- HTML学习-网页主体标记body(一)
- 用XPath查找HTML节点或元素
- XHTML表单
- 2.一些常见的html标签学习
- html.ex.day02
- html.ex.day01
- 写html文件一定要养成好习惯
- outerHTML
- html,图片上传预览,input file获取文件等相关操作