Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Hi All,
I am using "
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 10-Jan-13 22:45pm
Edited 11-Jan-13 2:15am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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++;
                }
        }
//Result is... result =1
//AND if search term is
string search = "left"
then result = 0
 
Thanks
Asp.Net/C#.Net Help[^]
Hemant Singh
  Permalink  
v5
Comments
Member 4531085 at 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
hemantrautela at 11-Jan-13 6:21am
   
not getting properly, can you give some input and desired output samples for better understanding.
Member 4531085 at 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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi,
 
This will help you :
 
Help[^]
  Permalink  

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



Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 11 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100