title: C# Write Word at the end, if string pattern contains
body: <p>I am trying to write code,</p>
  
  <p>any line which contains word 'ocean', I will write 'water' at the end</p>
  
  <p>how would I conduct this with RegeEx?</p>
  
  <p><strong>Sample:</strong></p>
  
  <pre><code>test1
  
  abcdocean123 
  
  
  test2
  test3
  </code></pre>
  
  <p><strong>Result (keeps all other spacing in file):</strong> </p>
  
  <pre><code>test1
  
  abcdocean123 water
  
  
  test2
  test3
  </code></pre>
  
  <p><strong>Code Attempt:</strong></p>
  
  <pre><code>    public string FileRead(string path)
      {
          content = File.ReadAllText(path);
          return content;
      }
  
      public string FileChange()
      {
  
          var lines = content.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)
                      .Select(line =&gt; Regex.Replace(line, @"\bocean\b\n", "water \n"));
          content = String.Join("\n", lines);
          return content;
      }
  </code></pre>