I have a string like:
\"super exemple of string key : text I want to keep - end of my string\"
I want to just keep the string which is betw
I used the code snippet from Vijay Singh Rana which basically does the job. But it causes problems if the firstString
does already contain the lastString
. What I wanted was extracting a access_token from a JSON Response (no JSON Parser loaded). My firstString
was \"access_token\": \"
and my lastString
was \"
. I ended up with a little modification
string Between(string str, string firstString, string lastString)
{
int pos1 = str.IndexOf(firstString) + firstString.Length;
int pos2 = str.Substring(pos1).IndexOf(lastString);
return str.Substring(pos1, pos2);
}