using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"([\w\.:-]*)=(\d)+(,|})";
string substitution = @"""\1"":\2\3";
string input = @"{ok_sock_to_host_close_10.205.148.134:32001=6, ok_sock_to_host_ssl1zn3-m1-ap.ssodev-bo.mtv1.vrsn.com:32001=6, ok_sock_to_host_10.205.148.134:32001=6, ok_sock_to_host_127.0.0.1:8080=5, ok_permit_to_host_acquired_127.0.0.1:8443=5, ok_sock_to_host_real_open_ssl1zn3-m1-ap.ssodev-bo.mtv1.vrsn.com:32001=2, ok_sock_to_host_real_open_10.205.148.134:32001=2, ok_permit_to_host_acquired_10.205.148.134:32001=6, fail_sock_to_host_127.0.0.1:8443=5, ok_permit_to_host_released_127.0.0.1:8080=5, ok_sock_to_host_real_close_ssl1zn3-m1-ap.ssodev-bo.mtv1.vrsn.com:32001=2, ok_sock_to_host_real_close_10.205.148.134:32001=2, ok_sock_to_host_close_ssl1zn3-m1-ap.ssodev-bo.mtv1.vrsn.com:32001=6, ok_sock_to_host_real_open_127.0.0.1:8080=5, ok_sock_to_host_real_close_127.0.0.1:8080=5, ok_sock_to_host_close_127.0.0.1:8080=5, ok_permit_to_host_released_127.0.0.1:8443=5, ok_permit_to_host_released_ssl1zn3-m1-ap.ssodev-bo.mtv1.vrsn.com:32001=6, ok_permit_to_host_acquired_ssl1zn3-m1-ap.ssodev-bo.mtv1.vrsn.com:32001=6, ok_permit_to_host_acquired_127.0.0.1:8080=5, ok_permit_to_host_released_10.205.148.134:32001=6}";
Regex regex = new Regex(pattern);
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