Just log on http://www.asp.net
Create your account and get VS2010, SQL Server 2008 R2 and Windows Server 2008 R2 for 3 years
Thursday, July 15, 2010
Wednesday, July 14, 2010
Regular Expression for Date
Regular Expression for date format MM/dd/yyyy
^([1-9]|0[1-9]|1[012])[/]([1-9]|0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d$
^([1-9]|0[1-9]|1[012])[/]([1-9]|0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d$
Convert HTML To Text
Below code convert html code into text form and remove all tags related to html, script and style etc. Code remove all tags with the help of regular expressions so you don't need any parser for this, and its more efficient then any parser.
public static string ConvertHTMLtoText(string input)
{
input = Regex.Replace(input, @"<script.*?>[\s\S]*?</.*?script>", "");
input = Regex.Replace(input, @"<style.*?>[\s\S]*?</.*?style>", "");
input = Regex.Replace(input, @"(<|</)( )*\w*>", "");
return input = Regex.Replace(input, @"<( )*([^>])*>", "");
}
public static string ConvertHTMLtoText(string input)
{
input = Regex.Replace(input, @"<script.*?>[\s\S]*?</.*?script>", "");
input = Regex.Replace(input, @"<style.*?>[\s\S]*?</.*?style>", "");
input = Regex.Replace(input, @"(<|</)( )*\w*>", "");
return input = Regex.Replace(input, @"<( )*([^>])*>", "");
}
Subscribe to:
Posts (Atom)