using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"timeout\shttp-request\s+\d+(?=[\s\S]+defaults)";
string input = @"global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 32768
tune.maxaccept -1
chroot /var/lib/haproxy
daemon
timeout http-request 5000
stats socket /var/run/haproxy.sock mode 600 level admin
stats timeout 2m
defaults
log global
mode http
option httplog
option dontlognull
retries 5
option redispatch
maxconn 16384
timeout connect 7s
timeout client 500s
timeout server 500s
timeout http-request 7000
timeout client-fin 30s
timeout tunnel 1h";
RegexOptions options = RegexOptions.Multiline;
Match m = Regex.Match(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