fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text.RegularExpressions;
  6.  
  7. public class Test
  8. {
  9. public static void Main()
  10. {
  11. var line = "this.Button.Value\nthis.value\ndocument.thisButton.Value";
  12. var word = "this";
  13. var rx =new Regex(string.Format(@"(?<=\s)\b{0}\b(?=\s)|\b{0}\b(?=\.)", word));
  14. var result = rx.Replace(line, "NEW_WORD");
  15. Console.WriteLine(result);
  16. }
  17. }
Success #stdin #stdout 0.11s 24656KB
stdin
Standard input is empty
stdout
NEW_WORD.Button.Value
NEW_WORD.value
document.thisButton.Value