避免使用Div标签内容 [英] Avoid Div tag content
问题描述
大家好,
我正在使用
Hi All,
I am using "
if (Regex.IsMatch(PageText, string.Format(@"\b({0})\b", TextToHighlights)))
{
TotalWordCount++;
lst.Add(TextToHighlights);
}
从我的数据库中过滤单词,但它也匹配div标签内的单词,我不想要单词,即从我的单词数据库匹配的属性(外部,图标)是匹配并增加计数,我想忽略div标签内的内容。
更具体一点,让我解释一下:
"
to filter words from my database , but it also match word inside div tag, i dont want word i.e attribute like (external, icon) that matches from my word database to be matched and increase the count, i want to ignore content inside div tag.
To be more specific let me explain a bit:
Let say i have word like "Icon,external,absolute" in my dictionary and this word also exist as attribute in HTML tag''s, but i want that this words only matches when it comes as content in browser not as attribute of html tag (like DIV, Href,img) and so on. Hope now you understand.
请帮助
谢谢
AP
Please help
Thanks
AP
推荐答案
我认为你需要删除你的html标签字符串,如果我是正确的,那么我将其描述如下链接...
remove-html-tags-from-string-c#.net-asp.net [ ^ ]
如果您的内容
Hi,
I think you need remove html tags from your string, If I am correct then I describe it as below link...
remove-html-tags-from-string-c#.net-asp.net[^]
If your content
string mytext = "<div style="float:left; removed:absolute">Some Text with absolute value.</div>";
如上所述调用我的函数链接...
call my function as describe above link...
string Input = replace(mytext );
现在你需要检查
now you need to check
string search = "absolute";
int length = search.Length;
int howmanytimes = Input.Length - length;
int result = 0;
for (int index = 0; index < howmanytimes; index++)
{
string theSubString = Input.Substring(index, length);
if (theSubString.ToLower() == search.ToLower())
{
result++;
}
}
//结果是......结果= 1
// AND如果搜索字词为
字符串搜索=左
则结果= 0
谢谢
Asp.Net/C#.Net帮助 [ ^ ]
Hemant Singh
//Result is... result =1
//AND if search term is
string search = "left"
then result = 0
Thanks
Asp.Net/C#.Net Help[^]
Hemant Singh
这将对您有所帮助:
帮助 [ ^ ]
这篇关于避免使用Div标签内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!