How to remove html tag from string using RegexGenerally we face a problem when we want show some html data to server control like Grid View or List View. We want to remove all the html tag from our string. For example we have following html data
char *ptr;
char myString[]="abcdefg";
ptr= myString;
ptr+=5;
What string does ptr points to in the sample code above?
We want to remove all html tag from above data. So for doing this we can use a simple Regular Expression. For this we have include following namespace
Using System.Text.RegularExpression
Then use the following code
String strData = Regex.Replace(str, @"<(.|\n)*?>", string.Empty); // here str variable hold html data
Now you will get data with no html tag like following
char *ptr;
char myString[]="abcdefg";
ptr= myString;
ptr+=5;
What string does ptr points to in the sample code above?