1

What I found out using this "\\${(.*?)\\}.

So I tried: new Regex(@"\\$\\${(.*?)\\}");

But this seems not to work, whats the problem here ?

Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142
ASfdsa33
  • 97
  • 1
  • 9
  • 1
    What's wrong with [string.Contains](https://msdn.microsoft.com/en-us/library/dy85x1sa(v=vs.110).aspx)? – Liam Sep 14 '16 at 14:59
  • You have a rare problem: **Just one *dollar* too much...** The second `$` is not needed... Try `new Regex(@"\\$\\{(.*?)\\}");` – ppeterka Sep 14 '16 at 14:59
  • Specifically read the comment on [this answer](http://stackoverflow.com/a/5848360/542251) – Liam Sep 14 '16 at 15:00
  • 1
    @Liam I think OP needs to match strings dynamically... I suspect OP wants to get the matched group in a later step... – ppeterka Sep 14 '16 at 15:01
  • 1
    @Liam I don't know the text between **${}** – ASfdsa33 Sep 14 '16 at 15:04

1 Answers1

3

I would use new Regex(@"\${(.*?)}");

Let's analyze yours:

(@"\\$\\${(.*?)\\}");
   ^^^^^^      ^^^
   ||||||      |||-- Your don't need to double your slashes in a literal string.
     \  |        |       
      \ |        |
       \|--------|-- You have 2 "$" and you just want one
                 |
                 |-- You don't need to escape "{" since it doesn't enclose digits
                     and can't be interpreted as a length attribute.
Thomas Ayoub
  • 29,063
  • 15
  • 95
  • 142