Question: I'm writing a CMS in ASP.NET/C#, and I need to process things like that, every page request:

```
<html>
<head>
    <title>[Title]</title>
</head>
<body>
    <form action="[Action]" method="get">
        [TextBox Name="Email", Background=Red]
        [Button Type="Submit"]
    </form>
</body>
</html>

```

and replace the [...] of course.

My question is how should I implement it, with ANTLR or with Regex? What will be faster? Note, that if I'm implementing it with ANTLR I think that I will need to implement XML, in addon to the [..]. 

I will need to implement parameters, etc.

**EDIT:** Please note that my regex can even look like something like that:

```
public override string ToString()
{
    return Regex.Replace(Input, @"\[
                                    \s*(?<name>\w+)\s*
                                    (?<parameter>
                                        [\s,]*
                                            (?<paramName>\w+)
                                            \s*
                                            =
                                            \s*
                                            (
                                                (?<paramValue>\w+)
                                                |
                                                (""(?<paramValue>[^""]*)"")
                                            )
                                    )*
                               \]", (match) =>
                                  {
                                      ...
                                  }, RegexOptions.IgnorePatternWhitespace);
}        

```

Answer: 
About the performance of ANTLR vs. RegEx depends on the implementation of RegEx in C#. I know, from experience, that ANTLR is fast enough.

In ANTLR you can ignore certain content, like the XML. You can also seek for the `[` and `]` and go further with processing.

Both RegEx and ANTLR are supporting your kind of parameters (the "etc." I'm not sure about).

In terms of development speed: RegEx is slightly faster for such a case like this. You can use an online tool to develop the RegEx and see the capture-groups while you edit the RegEx. (Google @ `regex gskinner`)

Then ANTLR has perfect support for "error-messages": they show line/column numbers and what was wrong. RegEx doesn't have this support.

A general approach for RegEx would be: create a "global scan" RegEx which will find correct `[`...`]` groups in your content. Then let the "..." be captuerd by a group, and then apply another RegEx for this smaller content (which splits content based on the equal-sign and commas). This way you have the best runtime performance and it's easy to develop.
If the language you are parsing is **regular** then **regular expressions** are certainly an option. If it is not then ANTLR may be your only choice. If I understand these matters correctly XML is not regular.