ajay raju
posted
207 posts
since
Jan 18, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
hi friend,
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 A
posted
9 posts
since
Jun 18, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
thanx ajay, how does your query string check for existence of <P>? Does it go with those conventions or it just counts the strings/words passed and limits it?
|
|
|
|
|
|
Tina Thomas
posted
9 posts
since
Jul 12, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
If the objective is to extract first n paragraphs, then extract the whole text from the database, and use a regular expression to extract the desired text.
|
|
|
|
|
|
Churchill A
posted
9 posts
since
Jun 18, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
Tina I think ur getting it. Do you have a method I can use? Maybe some sample code I can implement?
|
|
|
|
|
|
Tina Thomas
posted
9 posts
since
Jul 12, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
It can definitely be achieved using a simple array split..
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 A
posted
9 posts
since
Jun 18, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
Thanks a lot Tina: 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 Thomas
posted
9 posts
since
Jul 12, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
public string getSummary(string inputHTML) { string[] arrText = inputHTML.Split('\n'); return arrText[0] + arrText[1]+ arr[Text2]; }
|
|
|
|
|
|
Churchill A
posted
9 posts
since
Jun 18, 2010
from
|
|
Re: Extract first (n) number of paragraphs from a long text
|
|
|
|
|
|
|
|
|
|
|
T2 Thanks so so much for that. It has really saved me some headache!
|
|
|
|
|
|