How to replace the given email address with a value in a given input?
Performance wise using string concatination (output += ) inside a loop isn't the best choice because for each output +=  a new string is created because strings are immutable. Using a StringBuilder would be the way to go. But instead of returning a string, you could return an IEnumerable&lt;string&gt; which would make the code more flexible.

Passing an IEnumerable&lt;string&gt; as method parameter holding the not wanted domains will make the code open for needed changes.

Passing an IEnumerable&lt;string&gt; as method parameter holding the tokens would enable the method to only do one thing.

Because the method is public you should have proper parameter validation.

Using a little bit of Linq would compact the code a lot.

Instead of hardcoding &quot;SOMETEXT&quot; you could pass an optional parameter.


Implementing the mentioned changes using string as return-type would lead to
public static string RemovePersonalInfo(string input)
{
    if (input == null) { throw new NullReferenceException(nameof(input)); }
    if (string.IsNullOrWhiteSpace(input)) { return input; }

    return RemovePersonalInfo(input.Split(new char[] { ' ', '\t', '\r', '\n' }), new string[] { &quot;@gmail.com&quot;, &quot;@yahoo.com&quot; });

}
private static string RemovePersonalInfo(IEnumerable&lt;string&gt; tokens, IEnumerable&lt;string&gt; domains, string replacement = &quot;SOMETEXT&quot;)
{
    return string.Join(&quot; &quot;, tokens.Select(token =&gt; (domains.Any(domain =&gt; token.Contains(domain)) ? replacement : token)));
}  

and could be called like before.