fork(2) download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. public class Test
  7. {
  8.  
  9.  
  10. public static void Main()
  11. {
  12. string myString = "words words words FIRSTPHRASE these words I want SECONDPHRASE but not these words";
  13. int indexOfFirstPhrase = myString.IndexOf("FIRSTPHRASE");
  14. string result = myString;
  15. if(indexOfFirstPhrase >= 0)
  16. {
  17. indexOfFirstPhrase += "FIRSTPHRASE".Length;
  18. result = myString.Substring(indexOfFirstPhrase);
  19. int indexOfSecondPhrase = myString.IndexOf("SECONDPHRASE", indexOfFirstPhrase);
  20. if (indexOfSecondPhrase >= 0)
  21. {
  22. result = myString.Substring(indexOfFirstPhrase, indexOfSecondPhrase - indexOfFirstPhrase);
  23. }
  24. }
  25. Console.WriteLine(result);
  26. }
  27. }
Success #stdin #stdout 0.05s 33976KB
stdin
Standard input is empty
stdout
 these words I want