using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"pam\.username%([A-Za-z0-9]+)@|\s\(([0-9]+)\)";
string substitution = @"";
string input = @"Sep 11 03:02:00 (1568505720.145620) danted[10402]: info: pass(2): tcp/connect -: pam.username%MyUsername@46.111.111.250.48198 123.12.12.112.1080 -> 123.12.12.112.48198 111.123.123.147.443 (319721)
Sep 11 03:02:00 (1568505720.147471) danted[10402]: info: pass(2): tcp/connect -: pam.username%MyUsername@46.111.111.250.37449 123.12.12.112.1080 -> 123.12.12.112.37449 123.123.123.211.443 (312)
Sep 11 03:02:00 (1568505720.148240) danted[10402]: info: pass(2): tcp/connect -: 111.123.123.147.443 123.12.12.112.48198 -> 123.12.12.112.1080 pam.username%MyUsername@46.111.111.250.48198 (723)
Sep 11 03:02:00 (1568505720.154784) danted[10402]: info: pass(2): tcp/connect -: 123.123.123.211.443 123.12.12.112.37449 -> 123.12.12.112.1080 pam.username%MyUsername@46.111.111.250.37449 (8831)";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx