Skip to content

Instantly share code, notes, and snippets.

@jltrem
Created August 18, 2014 13:36
Show Gist options
  • Save jltrem/7dde417560f283f3f403 to your computer and use it in GitHub Desktop.
Save jltrem/7dde417560f283f3f403 to your computer and use it in GitHub Desktop.
// Return the text found between two other substrings.
public static string Substring(this string src, string startStr, string finishStr)
{
string substr = "";
int atStart = src.IndexOf(startStr);
if (atStart >= 0)
{
int afterStart = atStart + startStr.Length;
int atFinish = src.IndexOf(finishStr, afterStart);
if (atFinish >= 0)
{
substr = src.Substring(afterStart, atFinish - afterStart);
}
}
return substr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment