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 ThomasPosted Jul 24, 2010, 10:31 AM
{
string[] arrText = inputHTML.Split('\n');
return arrText[0] + arrText[1]+ arr[Text2];
}
Churchill APosted Jul 26, 2010, 8:36 AM
Churchill APosted Jul 24, 2010, 10:10 AM
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.
Tina ThomasPosted Jul 24, 2010, 9:52 AM
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 APosted Jul 24, 2010, 7:15 AM
Tina ThomasPosted Jul 24, 2010, 6:49 AM
Churchill APosted Jul 24, 2010, 6:28 AM
? Does it go with those conventions or it just counts the strings/words passed and limits it?
ajay rajuPosted Jul 24, 2010, 5:52 AM
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.