The C# expression library I am using will not directly support my table/field parameter syntax:
The following are table/field parameter names that are not directly suppo
I've written a completely new answer, now that the problem is clarified:
You can do this in a single regex. It is quite bulletproof, I think, but as you can see, it's not exactly self-explanatory, which is why I've commented it liberally. Hope it makes sense.
You're lucky that .NET allows re-use of named capturing groups, otherwise you would have had to do this in several steps.
resultString = Regex.Replace(subjectString,
@"(?: # Either match...
(? # (and capture into backref )
(?=\w*\p{L}) # (as long as it contains at least one letter):
\w+ # one or more alphanumeric characters,
) # (End of capturing group ).
\. # then a literal dot,
(? # (now capture again, into backref )
(?=\w*\p{L}) # (as long as it contains at least one letter):
\w+ # one or more alphanumeric characters.
) # (End of capturing group ) and end of match.
| # Or:
\[ # Match a literal [
(? # (now capture into backref )
[^\]]+ # one or more characters except ]
) # (End of capturing group ).
\]\.\[ # Match literal ].[
(? # (capture into backref )
[^\]]+ # one or more characters except ]
) # (End of capturing group ).
\] # Match a literal ]
) # End of alternation. The match is now finished, but
(?= # only if the rest of the line matches either...
[^']*$ # only non-quote characters
| # or
[^']*'[^']*' # contains an even number of quote characters
[^']* # plus any number of non-quote characters
$ # until the end of the line.
) # End of the lookahead assertion.",
"[${before}|${after}]", RegexOptions.Multiline | RegexOptions.IgnorePatternWhitespace);