Between of two strings
问题 I have simple method in C# : public static string BetweenOf(string ActualStr, string StrFirst, string StrLast) { return ActualStr.Substring(ActualStr.IndexOf(StrFirst) + StrFirst.Length, (ActualStr.Substring(ActualStr.IndexOf(StrFirst))).IndexOf(StrLast) + StrLast.Length); } How can i optimise this ? 回答1: Here's how the code from @Chris here stacks up against a regular expression test: void Main() { string input = "abcdefghijklmnopq"; string first = "de"; string last = "op"; Regex re1 = new