title: How can I get this regex right in c#?
body: <p>I am trying to match any blocks that has <code>type:"Data"</code> in it and then replace it with the text I want.<br>
  A sample input is given below, there can be one or more of these:  </p>
  
  <pre><code>layer {
    name: "cifar"
    type: "Data"
    top: "data"
    top: "label"
    include {
      phase: TRAIN
    }
    transform_param {
      mean_file: "examples/cifar10/mean.binaryproto"
      mirror: true
      #crop_size: 20 
    }
  
  # this is a comment!
    data_param {
      source: "examples/cifar10/cifar10_train_lmdb"
      batch_size: 100
      backend: LMDB
    }
  }
  layer {
    name: "cifar"
    type: "Data"
    top: "data"
    top: "label"
    include {
      phase: TEST
    }
    transform_param {
      mean_file: "examples/cifar10/mean.binaryproto"
    }
    data_param {
      source: "examples/cifar10/cifar10_test_lmdb"
      batch_size: 25
      backend: LMDB
    }
  }
  </code></pre>
  
  <p>I came up with this regex :   </p>
  
  <pre><code>((layer)( *)((\n))*{((.*?)(\n)*)*(type)( *):( *)("Data")((.*?)(\n)*)*)(.*?)(\n)}
  </code></pre>
  
  <p>I tried to model this : </p>
  
  <pre><code>find and select a block starting with layer, 
  there can be any number of space characters but after it 
  there should be a { character, 
  then there can be anything( for making it easier), and then 
  there should be a type followed by any number of spaces, then followed by "Data"
  then anything can be there, until it is faced with a } character 
  </code></pre>
  
  <p>But clearly this does not work properly. If I change the type in any of these layer blocks, nothing gets detected!, not even the layer which has the <code>type : "Data"</code> </p>