using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"#opening tag
\{(RAW|ACCESS|DWNLINK|MODL|\w+)
#optional attributes
(?>
\{ ([^}]*) }
)?
}
#optional text and closing tag
(?:
( #text:= any char except ""{"", or a ""{"" not followed by /commandname
[^{]*+
(?>\{(?!/?\1[{}])[^{]*)*?
)
#closing tag
\{/\1}
)?";
string input = @"<div class=""blog-list-item blog""><header class=""entry-title"">
<h1>Welcome to our website</h1>
</header><article id=""entry-72"" class=""entry post-72 page et-bg-layout-dark et-white-bg""><div class=""jumbotron row"">
<div class=""col-md-8"">
<ul>
<li>You have a pending job on your neck?…</li>
<li>Do your company need a website makeover ?…</li>
<li>Or a competitive web application ? ?…</li>
<li>Do you need a customized plugin, or a tweak ?…</li>
<li>Maybe you want a personal website ?…</li>
<li>Or a graphic for your new project ?…</li>
</ul>
<div class=""bg-primary well"">
<h4 class=""text-center text-white shadow"">Track your project as we work it to perfection...</h4>
</div>
</div>
<div class=""pull-right col-md-4"">
<h4 class=""bg-primary text-white well"">Other services we offer</h4>
{ACCESS{type=500}}
<ul>
<li>SEO work for an existing website or new</li>
<li>Bulk SMS</li>
<li>E-currency exchange</li>
<li>Facebook AD</li>
<li>Google AD</li>
</ul>
{/ACCESS}</div>
{RAW{say=email,access=500}} {RAW} <a class=""btn button large tall green"" href=""client-area"">Place new Job now as we deliver at the quickest <em>reasonable time</em></a>{/RAW}</div></article></div>";
RegexOptions options = RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace;
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