Krishna Krishna - 21 days ago 4x
C# Question

Remove not used Merge tags Regular expression

I am using C# and writing mail merge application. My users store the templates as follows

Dear [[-UserName-]],
You have been subscribed for [[-SubscriptionName-]]...

and so on. There will be lot of custom fields between
place holders. I am merging them fine. But sometimes they don't pass for some place holders. I would like to find those things using regular expressions and replace them with empty strings.

Technically, I want to find out the regular expression to find
[[-what ever it is in between-]]
and replace with empty string along with

Jan Jan

You can use:

# look for [[-, -]] and anything in between.

This is called a lazy dot star, see a demo on