protected Regex _tagsRegExp = new Regex("?\\w+(?:(?:\\s+\\w+(?:\\s*=\\s*(?:\".*?\"'.*?'[^'\">\\s]+))?)+\\s*\\s*)/?>", RegexOptions.Compiled RegexOptions.IgnoreCase);
private string GetSummary(string text, int wordLimit)
{
try
{
//return input string directly if its empty/null.
if (!string.IsNullOrEmpty(text))
{
string inputText = _tagsRegExp.Replace(text, "").Replace(" ", " "); //gossip has case...
return getWordFromString(inputText, wordLimit);
}
else
{
return text;
}
}
catch (Exception ex) //This may catch if allowed Len is less than zero
{
ExceptionLog.Write(ex, "Unable to extract text from the string. The string len:" + text.Length + " and the word limit was : " + wordLimit);
return text;
}
}
Thursday, October 29, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment