1

I have a doc which I load with interop. I need to find match content with a regex. Some words in the doc are between $$ : $$theWord$$ So I need to get all of them for displaying to user and know what he wants to set for replace.

object fileName = System.IO.Path.Combine(templatePath, pj.Nom);
object missing = Type.Missing;
Application word = new Application();
Document doc = word.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing,
                                                ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                                                ref missing, ref missing, ref missing, ref missing);
doc.Activate();
string content = ((dynamic)doc).Content.Text;
Regex regex = new Regex(@"\$\$.*\$\$$", RegexOptions.Multiline);

List<string> tags = regex.Matches(content).Cast<string>().ToList();

The problem is my regex get only one word who begin on the first && found and finish on the last...

Please help me, I hate regex :(

Shadam
  • 1,041
  • 13
  • 25

0 Answers0