fork(40) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.IO;
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var searchString = "to find";
  9. var pattern = @"\b" + searchString + @"\b"; //searchString is passed in.
  10. Regex rgx = new Regex(pattern);
  11. var sentence = "I need to find a string in this sentence!";
  12. Match match = rgx.Match(sentence);
  13. if (match.Success)
  14. {
  15. Console.WriteLine(match.Value);
  16. }
  17. }
  18.  
  19. }
Success #stdin #stdout 0.1s 24600KB
stdin
Standard input is empty
stdout
to find