Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public string GetTextBetween(string firstPart, string secondPart, string lastPart)
- {
- string cleanCombo1 = string.Empty;
- string cleanCombo2 = string.Empty;
- string cleanCombo3 = string.Empty;
- string cleanCombo4 = string.Empty;
- string st1 = plHTMLP1.Text;
- int pFrom1 = st1.IndexOf(firstPart) + firstPart.Length;
- int pTo1 = st1.IndexOf(lastPart, pFrom1);
- if (st1.Substring(pFrom1, pTo1 - pFrom1).Contains(secondPart))
- {
- cleanCombo1 = st1.Substring(pFrom1, pTo1 - pFrom1);
- }
- string st2 = plHTMLP2.Text;
- int pFrom2 = st2.IndexOf(firstPart) + firstPart.Length;
- int pTo2 = st2.IndexOf(lastPart, pFrom2);
- if (st2.Substring(pFrom2, pTo2 - pFrom2).Contains(secondPart))
- {
- cleanCombo2 = st2.Substring(pFrom2, pTo2 - pFrom2);
- }
- string st3 = plHTMLP3.Text;
- int pFrom3 = st3.IndexOf(firstPart) + firstPart.Length;
- int pTo3 = st3.IndexOf(lastPart, pFrom3);
- if (st3.Substring(pFrom3, pTo3 - pFrom3).Contains(secondPart))
- {
- cleanCombo3 = st3.Substring(pFrom3, pTo3 - pFrom3);
- }
- string st4 = plHTMLP4.Text;
- int pFrom4 = st4.IndexOf(firstPart) + firstPart.Length;
- int pTo4 = st4.IndexOf(lastPart, pFrom4);
- if (st4.Substring(pFrom4, pTo4 - pFrom4).Contains(secondPart))
- {
- cleanCombo4 = st4.Substring(pFrom4, pTo4 - pFrom4);
- }
- return cleanCombo1 + cleanCombo2 + cleanCombo3 + cleanCombo4;
- }
- private void mButton_Click(object sender, EventArgs e)
- {
- string firstPart = "<strong>http://m2.";
- string secondPart = "m.com</strong>";
- string lastPart = "</p>";
- string textBetween = GetTextBetween(firstPart, secondPart, lastPart);
- plHTML.Text = FilterHTML(textBetween, "m.com");
- }
- public string FilterHTML(string cleanCombo, string EndOfString)
- {
- return cleanCombo.Replace("<strong>", "").Replace("<br />", "").Replace("</strong>", "").Replace(EndOfString, "");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement