using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"hw_state:\sElements\(temp:\s(?<temp>\d+)";
string input = @"{""bootcount"":8,""device_id"":""XXXX"",""environment"":""prod_walker"",""event_source"":""appliance"",""event_type"":""GENERIC"",""local_time"":""2025-02-20T00:34:58.406-06:00"",
""location"":{""city"":""XXXX"",""country"":""XXXX"",""latitude"":XXXX,""longitude"":XXXX,""state"":""XXXX""},""log_level"":""info"",
""message"":""martini::hardware_controller: Unit state update from cook client target: Elements(temp: 500°F, [D, D, D, D, D, F: 0]), hw_state: Elements(temp: 500°F, [D, D, D, D, D, F: 115])\u0000"",
""model_number"":""XXXX"",""sequence"":372246,""serial"":""XXXX"",""software_version"":""2.3.0.276"",""ticks"":0,""timestamp"":1740033298,""timestamp_ms"":1740033298406}";
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