Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
4.50/5 (2 votes)
See more:
Hi All,
I am using "
C#
if (Regex.IsMatch(PageText, string.Format(@"\b({0})\b", TextToHighlights)))
                        {
                            TotalWordCount++;
                            lst.Add(TextToHighlights);
                        }

"
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.


Please help

Thanks
AP
Posted
Updated 11-Jan-13 2:15am
v2

Hi,

This will help you :

Help[^]
 
Share this answer
 
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
C#
string mytext = "<div style="float:left; removed:absolute">Some Text with absolute value.</div>";


call my function as describe above link...

C#
string Input = replace(mytext );

now you need to check

C#
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++;
        }
}

//Result is... result =1
//AND if search term is
string search = "left"
then result = 0

Thanks
Asp.Net/C#.Net Help[^]
Hemant Singh
 
Share this answer
 
v5
Comments
Member 4531085 11-Jan-13 6:12am    
Thanks for the reply but i dont want to ignore all the tags but i want to ignore content inside html tag but tag should be remain their
Hemant Singh Rautela 11-Jan-13 6:21am    
not getting properly, can you give some input and desired output samples for better understanding.
Member 4531085 11-Jan-13 8:14am    
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.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900