Extract first (n) number of paragraphs from a long text
I have a long text from the db and I would like a method to only output the first 3 paragraphs or something like that. Its retrieved from the database and has HTML codes too. How do I go about this?

Tina Thomas18 reputationPosted Jul 24, 2010, 6:31 AM EDT
{
string[] arrText = inputHTML.Split('\n');
return arrText[0] + arrText[1]+ arr[Text2];
}
ajay rajuRank #4,639 · 333 reputationPosted Jul 24, 2010, 1:52 AM EDT
in your select query use this below example Query
SELECT empID,empName,CASE WHEN LEN(Description) > 30 THEN SUBSTRING(Description,0,25) + '....' ELSE Description END AS Description FROM emp
empID,Ename,Description are columns of my empo table.
if it helps you please check mark as accept answer.
Thanks.
Churchill A14 reputationPosted Jul 24, 2010, 2:28 AM EDT
? Does it go with those conventions or it just counts the strings/words passed and limits it?
Tina Thomas18 reputationPosted Jul 24, 2010, 2:49 AM EDT
Churchill A14 reputationPosted Jul 24, 2010, 3:15 AM EDT
Tina Thomas18 reputationPosted Jul 24, 2010, 5:52 AM EDT
string[] arrText = sText.Split('\n');
foreach(string sExtractText in arrText)
{
}
Or using a regular expression like this:
// Regex comments .-> matches any single character except \n
// * -> matches preceeding character any number of times
//$-> end of the string
Regex r = new Regex(@"(.*$)", RegexOptions.Multiline);
Match m;
string sExtract = "";
// This gives the groups of matched strings where the processing can be done
for (m = r.Match(sText); m.Success; m = m.NextMatch())
{
sExtract = m.Groups[1].Value;
}
Churchill A14 reputationPosted Jul 24, 2010, 6:10 AM EDT
Assuming I have
public string getSummary(string inputHTML){
}
Please help me construct that and return a string that has only the first 3 paragraphs,
Thanx.
Churchill A14 reputationPosted Jul 26, 2010, 4:36 AM EDT