Advertisement
Guest User

Untitled

a guest
Jun 4th, 2015
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. public string GetTextBetween(string firstPart, string secondPart, string lastPart)
  2. {
  3.     string cleanCombo1 = string.Empty;
  4.     string cleanCombo2 = string.Empty;
  5.     string cleanCombo3 = string.Empty;
  6.     string cleanCombo4 = string.Empty;
  7.  
  8.     string st1 = plHTMLP1.Text;
  9.     int pFrom1 = st1.IndexOf(firstPart) + firstPart.Length;
  10.     int pTo1 = st1.IndexOf(lastPart, pFrom1);
  11.     if (st1.Substring(pFrom1, pTo1 - pFrom1).Contains(secondPart))
  12.     {
  13.         cleanCombo1 = st1.Substring(pFrom1, pTo1 - pFrom1);
  14.     }
  15.  
  16.     string st2 = plHTMLP2.Text;
  17.     int pFrom2 = st2.IndexOf(firstPart) + firstPart.Length;
  18.     int pTo2 = st2.IndexOf(lastPart, pFrom2);
  19.     if (st2.Substring(pFrom2, pTo2 - pFrom2).Contains(secondPart))
  20.     {
  21.         cleanCombo2 = st2.Substring(pFrom2, pTo2 - pFrom2);
  22.     }
  23.  
  24.     string st3 = plHTMLP3.Text;
  25.     int pFrom3 = st3.IndexOf(firstPart) + firstPart.Length;
  26.     int pTo3 = st3.IndexOf(lastPart, pFrom3);
  27.     if (st3.Substring(pFrom3, pTo3 - pFrom3).Contains(secondPart))
  28.     {
  29.         cleanCombo3 = st3.Substring(pFrom3, pTo3 - pFrom3);
  30.     }
  31.  
  32.     string st4 = plHTMLP4.Text;
  33.     int pFrom4 = st4.IndexOf(firstPart) + firstPart.Length;
  34.     int pTo4 = st4.IndexOf(lastPart, pFrom4);
  35.     if (st4.Substring(pFrom4, pTo4 - pFrom4).Contains(secondPart))
  36.     {
  37.         cleanCombo4 = st4.Substring(pFrom4, pTo4 - pFrom4);
  38.     }
  39.  
  40.     return cleanCombo1 + cleanCombo2 + cleanCombo3 + cleanCombo4;
  41. }
  42.  
  43. private void mButton_Click(object sender, EventArgs e)
  44. {
  45.     string firstPart = "<strong>http://m2.";
  46.     string secondPart = "m.com</strong>";
  47.     string lastPart = "</p>";
  48.     string textBetween = GetTextBetween(firstPart, secondPart, lastPart);
  49.     plHTML.Text = FilterHTML(textBetween, "m.com");
  50. }
  51.  
  52. public string FilterHTML(string cleanCombo, string EndOfString)
  53. {
  54.     return cleanCombo.Replace("<strong>", "").Replace("<br />", "").Replace("</strong>", "").Replace(EndOfString, "");
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement