using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?<vendor_date>\d{4}(?:\-\d\d){2} [^,]+,[^:]+):(?<vendor_level>[^:]+):(?<vendor_component>[^:]+):(?<vendor_message>[^\n\r]+)(?<vendor_details>(?(?=^\d{4}(?:\-\d\d){2})|[^\r])+)?";
string input = @"2019-10-14 11:07:08,727:DEBUG:certbot.cli:Var dry_run=True (set by user).
2019-10-14 11:07:08,727:DEBUG:certbot.cli:Var server={'dry_run', 'staging'} (set by user).
2019-10-14 11:07:08,727:DEBUG:certbot.cli:Var dry_run=True (set by user).
2019-10-14 11:07:08,728:DEBUG:certbot.cli:Var server={'dry_run', 'staging'} (set by user).
2019-10-14 11:07:08,728:DEBUG:certbot.cli:Var account={'server'} (set by user).
2019-10-14 11:07:08,757:INFO:certbot.renewal:Cert not due for renewal, but simulating renewal for dry run
2019-10-14 11:07:08,757:DEBUG:certbot.plugins.selection:Requested authenticator nginx and installer nginx
2019-10-14 11:07:10,881:DEBUG:certbot.plugins.selection:Single candidate plugin: * nginx
Description: Nginx Web Server plugin
Interfaces: IAuthenticator, IInstaller, IPlugin
Entry point: nginx = certbot_nginx.configurator:NginxConfigurator
Initialized:
Prep: True
2019-10-14 11:07:10,888:DEBUG:certbot.plugins.selection:Single candidate plugin: * nginx
Description: Nginx Web Server plugin
Interfaces: IAuthenticator, IInstaller, IPlugin
Entry point: nginx = certbot_nginx.configurator:NginxConfigurator
Initialized:
Prep: True
2019-10-14 11:07:10,889:DEBUG:certbot.plugins.selection:Selected authenticator and installer
2019-10-14 11:07:10,889:INFO:certbot.plugins.selection:Plugins selected: Authenticator nginx, Installer nginx
2019-10-14 11:07:10,902:DEBUG:certbot.main:Picked account: )>), only_return_existing=None, contact=('mailto:trol@yopmail.com',), agreement='https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf')), 019763ae9d0030f2ffa8f8cb689e7976, Meta(creation_dt=datetime.datetime(2018, 2, 27, 14, 17, 55, tzinfo=), creation_host='sd-99715.dedibox.fr'))>
2019-10-14 11:07:10,911:DEBUG:acme.client:Sending GET request to https://acme-staging-v02.api.letsencrypt.org/directory.
2019-10-14 11:07:10,998:DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): acme-staging-v02.api.letsencrypt.org
2019-10-14 11:07:14,617:DEBUG:requests.packages.urllib3.connectionpool:https://acme-staging-v02.api.letsencrypt.org:443 ""GET /directory HTTP/1.1"" 200 724
2019-10-14 11:07:14,619:DEBUG:acme.client:Received response:
HTTP 200
Server: nginx
Date: Mon, 14 Oct 2019 09:07:14 GMT
Content-Type: application/json
Content-Length: 724
Connection: keep-alive
Cache-Control: public, max-age=0, no-cache
X-Frame-Options: DENY
Strict-Transport-Security: max-age=604800
{
""kRr68eKT_x4"": ""https://community.letsencrypt.org/t/adding-random-entries-to-the-directory/33417"",
""keyChange"": ""https://acme-staging-v02.api.letsencrypt.org/acme/key-change"",
""meta"": {
""caaIdentities"": [
""letsencrypt.org""
],
""termsOfService"": ""https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf"",
""website"": ""https://letsencrypt.org/docs/staging-environment/""
},
""newAccount"": ""https://acme-staging-v02.api.letsencrypt.org/acme/new-acct"",
""newNonce"": ""https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce"",
""newOrder"": ""https://acme-staging-v02.api.letsencrypt.org/acme/new-order"",
""revokeCert"": ""https://acme-staging-v02.api.letsencrypt.org/acme/revoke-cert""
}
2019-10-14 11:07:14,620:INFO:certbot.main:Renewing an existing certificate
2019-10-14 11:07:14,999:DEBUG:acme.client:Requesting fresh nonce
2019-10-14 11:07:15,006:DEBUG:acme.client:Sending HEAD request to https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce.
2019-10-14 11:07:15,156:DEBUG:requests.packages.urllib3.connectionpool:https://acme-staging-v02.api.letsencrypt.org:443 ""HEAD /acme/new-nonce HTTP/1.1"" 200 0
2019-10-14 11:07:15,158:DEBUG:acme.client:Received response:
HTTP 200
Server: nginx
Date: Mon, 14 Oct 2019 09:07:15 GMT
Connection: keep-alive
Cache-Control: public, max-age=0, no-cache
Link: https://acme-staging-v02.api.letsencrypt.org/directory;rel=""index""
Replay-Nonce: 0002fqXrdxZwV_xxxxx-xxxxxxxx-KdWhvOCtgFh5YNNVM
X-Frame-Options: DENY
Strict-Transport-Security: max-age=604800
2019-10-14 11:07:15,158:DEBUG:acme.client:Storing nonce: 0002fqXrdxZwV_xxxxx-xxxxxxxx-KdWhvOCtgFh5YNNVM
2019-10-14 11:07:15,160:DEBUG:acme.client:JWS payload:
b'{\n ""identifiers"": [\n {\n ""type"": ""dns"",\n ""value"": ""site.tld""\n },\n {\n ""type"": ""dns"",\n ""value"": ""cdn-css. site.tld ""\n },\n {\n ""type"": ""dns"",\n ""value"": ""cdn-js-body. site.tld ""\n },\n {\n ""type"": ""dns"",\n ""value"": ""cdn-js-footer. site.tld ""\n },\n {\n ""type"": ""dns"",\n ""value"": ""cdn-js-head. site.tld ""\n },\n {\n ""type"": ""dns"",\n ""value"": ""www. site.tld ""\n }\n ]\n}'
2019-10-14 11:07:15,173:DEBUG:acme.client:Sending POST request to https://acme-staging-v02.api.letsencrypt.org/acme/new-order:
{
""protected"": ""SOmeBASE64Str"",
""payload"": ""ANOTHERB64STR"",
""signature"": ""YETANOTHERB64STR""
}
2019-10-14 11:07:15,387:DEBUG:requests.packages.urllib3.connectionpool:https://acme-staging-v02.api.letsencrypt.org:443 ""POST /acme/new-order HTTP/1.1"" 201 1104";
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