using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?:""id\.resp_h""[""\[:]*|""rx_hosts""[""\[:]*)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})";
string input = @"schema_id=17127524534057985804:skip_writers="":{""_path"":""conn"",""_system_name"":""hostname"",""_write_ts"":""2020-01-12T22:09:28.853417Z"",""ts"":""2020-01-12T22:07:14.642074Z"",""uid"":""Cm4cbmvRjlmd2I52c"",""id.orig_h"":""192.168.1.1"",""id.orig_p"":xxx,""id.resp_h"":""192.168.1.2"",""id.resp_p"":xxx,""proto"":""udp"",
schema_id=17223896091372211545:skip_writers="":{""_path"":""files"",""_system_name"":""Hostname"",""_write_ts"":""2020-01-12T22:09:00.016260Z"",""ts"":""2020-01-12T22:07:14.108217Z"",""fuid"":""FnmzOv3Fkhr8lP0qL"",""tx_hosts"":[""192.168.1.1"",""192.168.1.1""],""rx_hosts"":[""192.168.1.10""],";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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