bita hekmat

bita hekmat

  • NA
  • 8
  • 3.5k

Get All strings between two strings

Jul 25 2015 3:27 PM

I have a string like that :

  "reasons why i love you i loveeeeee you very much,i never forget you ";
  i want to just keep the string which is between "i" and "you".i wrote this code
   
   1- love
   2- loveeeeee
   3-never forget
  i wrote this code ,but that isn't working properly
 

 
//**************
 
var input = "reasons why i love you i loveeeeee you very much,i never forget you ";
string start = "i";
string end = "you";

var pattern = start + @"\s*(.*?)\s*" + end;




for (int i = 0; i <= Regex.Match(input, pattern).Groups.Count - 1; i++)
{
var result = Regex.Match(input, pattern).Groups[i].Value;
MessageBox.Show(result);
 
 
 
 
//*********
 

Answers (1)