I am trying to build a regular expression, but need help...
"<b>This</b> is some foobar text <b>bundled</b> up in a string..."
In the above text I want to find all occurances of "b", except where the text is "<b>This</b>" or "<b>bundled</b>".
So i dont want to find any Bs (case insensative) in "<b>This</b>" or "<b>bundled</b>", but only in "foobar".
The reason for this is I am trying to create a .net function to highlight my search results - My search page can take several words, and will search for all of the words. The search is done on database records with no html tags or anything. I can do a standard replace which works fine, but as soon as it comes to highlighting more than one word per record, i get problems.
Let me explain:
The record string is: "This is some foobar text bundled up in a string..."
I want to search for "t b".
First i will highlight all occurances of "t" (case insensative) with "<b>t</b>".
So all occurances of "t" will now be bold. The html will be: "<b>T</b>his is some foobar <b>t</b>ex<b>t</b> bundled up in a s<b>t</b>ring..."
Now i need to go and highlight all occurences of "b" - Now there are html tags in the text which include "b"s, so i get unwanted results: "<<b>b</b>>T</<b>b</b>>his is some foo<b>b</b>ar <<b>b</b>>t</<b>b</b>>ex<<b>b</b>>t</<b>b</b>> <b>b</b>undled up in a s<<b>b</b>>t</<b>b</b>>ring..."
So my solution would be to make sure that all html tags are ignored..?
Any help would be great!
"<b>This</b> is some foobar text <b>bundled</b> up in a string..."
In the above text I want to find all occurances of "b", except where the text is "<b>This</b>" or "<b>bundled</b>".
So i dont want to find any Bs (case insensative) in "<b>This</b>" or "<b>bundled</b>", but only in "foobar".
The reason for this is I am trying to create a .net function to highlight my search results - My search page can take several words, and will search for all of the words. The search is done on database records with no html tags or anything. I can do a standard replace which works fine, but as soon as it comes to highlighting more than one word per record, i get problems.
Let me explain:
The record string is: "This is some foobar text bundled up in a string..."
I want to search for "t b".
First i will highlight all occurances of "t" (case insensative) with "<b>t</b>".
So all occurances of "t" will now be bold. The html will be: "<b>T</b>his is some foobar <b>t</b>ex<b>t</b> bundled up in a s<b>t</b>ring..."
Now i need to go and highlight all occurences of "b" - Now there are html tags in the text which include "b"s, so i get unwanted results: "<<b>b</b>>T</<b>b</b>>his is some foo<b>b</b>ar <<b>b</b>>t</<b>b</b>>ex<<b>b</b>>t</<b>b</b>> <b>b</b>undled up in a s<<b>b</b>>t</<b>b</b>>ring..."
So my solution would be to make sure that all html tags are ignored..?
Any help would be great!