1namespace Crop.Retorna
2{
3 using System.Text.RegularExpressions;
4
5 public class cropRetorna
6 {
7 public string CropSentence(string textCrop, int num, string trail)
8 {
9 int iMax;
10 Regex rx = new Regex("<[^>]*>");
11
12 textCrop = rx.Replace(textCrop, "");
13
14 iMax = num - trail.Length;
15
16 if (iMax <= 0)
17 {
18 return "";
19 }
20 else if (textCrop.Length <= num)
21 {
22 return textCrop;
23 }
24 else
25 {
26 #region Crop ...
27
28
29 string sOut;
30 sOut = textCrop.Substring(0, num);
31
32 int iPos;
33 iPos = sOut.LastIndexOf(" ");
34
35 return sOut.Substring(0, iPos) + trail;
36 #endregion
37 }
38 }
39 }
40}