title: Match and replace
body: <p>I have a long string and <strong>within</strong> that string I have the following text:</p>
  
  <pre><code>"formatter": "SomeInformationHere"
  </code></pre>
  
  <p>I need to find the above text within the long string and remove the double quote marks around <strong>SomeInformationHere</strong> so the result looks like the below, but the quotes around the word "formatter" must remain.</p>
  
  <pre><code>"formatter": SomeInformationHere
  </code></pre>
  
  <p>I tried the below, which finds the string, but I'm not sure how to replace just the quotation marks around the value <strong>SomeInformationHere</strong>:</p>
  
  <pre><code>string pattern = "\"formatter\": ([\"]).*([\"])";
  Match match = Regex.Match(myString, pattern, RegexOptions.IgnoreCase);
  //Replace text in "myString" here
  myString = ?????
  //Output match value:
  Response.Write(match.Value);
  </code></pre>
  
  <p>Edit: Oh I forgot to mention that the above pattern could be in the "mystring" more than once and all will need the replacement doing on them.</p>
  
  <hr>
  
  <p>Edit 2:</p>
  
  <p>I've had a look at the regex tester site (thanks for the link) and pasted in my test string and regex pattern, it seems to work in that, but when I put the same pattern into dot net the replacement seems to work as if the "singleline" option has been selected. Below is the code I've used.</p>
  
  <ol>
  <li><p>The string - <strong>note that this does NOT contain any carriage returns - it's one long string that has been built from an XML file.</strong> Formatted for readability.</p>
  
  <pre><code>{
          "chart": {
                  "borderRadius": 15,
                  "borderWidth": 1,
                  "renderTo": "ChartContainer1",
                  "type": "pie"
          },
          "credits": {
                  "enabled": false
          },
          "labels": {
                  "items": [{
                          "html": "Label 1",
                          "style": {
                                  "left": "10px",
                                  "top": "30px"
                          }
                  }, {
                          "html": "Label 2",
                          "style": {
                                  "left": "10px",
                                  "top": "50px"
                          }
                  }, {
                          "dummy": null
                  }]
          },
          "plotOptions": {
                  "pie": {
                          "allowPointSelect": true,
                          "cursor": "pointer",
                          "showInLegend": true
                  }
          },
          "series": [{
                  "data": [{
                          "name": "Firefox",
                          "y": 45.0
                  }, {
                          "name": "IE",
                          "y": 26.8
                  }, {
                          "name": "Chrome",
                          "selected": true,
                          "sliced": true,
                          "y": 12.8
                  }, {
                          "name": "Safari",
                          "y": 8.5
                  }, {
                          "name": "Opera",
                          "y": 6.2
                  }, {
                          "name": "Others",
                          "y": 0.7
                  }],
                  "name": "Browser share"
          }, {
                  "dummy": null
          }],
          "test": {
                  "formatter": "function(){return \u0027\u0027+ this.point.name +\u0027&lt;\/b&gt;: \u0027+ this.y +\u0027 %\u0027;}"
          },
          "title": {
                  "align": "center",
                  "text": "Your chart title here"
          },
          "tooltip": {
                  "formatter": "function(){return \u0027\u0027+ this.point.name +\u0027&lt;\/b&gt;: \u0027+ this.y +\u0027 %\u0027;}"
          }
  }
  </code></pre></li>
  </ol>
  
  <p>As you can see near the bottom next to "test" and "tooltip" I have the "formatter:" part. the patten I'm currently using works when the above string is all on several lines (with CRs) in the tester, but when I put it on ONE line like it should be then the pattern doens't work</p>
  
  <p>The .NET code / pattern I'm using is:</p>
  
  <pre><code>string pattern = "(\"formatter\": )\"(.*)\"( })";
  var regex = new Regex(pattern, RegexOptions.IgnoreCase);
  aJSON = regex.Replace(aJSON, "$1$2$3");
  </code></pre>
  
  <p>thanks again. but I still can't seem to get the pattern to work correctly in the tester.</p>
  
  <p>Target string in the REGex tester site: (with no CRs)</p>
  
  <pre><code>{"chart": {"borderRadius": 15, "borderWidth": 1, "renderTo": "ChartContainer1", "type": "pie" }, "credits": {"enabled": false }, "labels": { "items": [ {"html": "Label 1", "style": {"left": "10px", "top": "30px" } }, {"html": "Label 2", "style": {"left": "10px", "top": "50px" } }, {"dummy": null } ] }, "plotOptions": {"pie": {"allowPointSelect": true, "cursor": "pointer", "showInLegend": true } }, "series": [ { "data": [ {"name": "Firefox", "y": 45.0 }, {"name": "IE", "y": 26.8 }, {"name": "Chrome", "selected": true, "sliced": true, "y": 12.8 }, {"name": "Safari", "y": 8.5 }, {"name": "Opera", "y": 6.2 }, {"name": "Others", "y": 0.7 } ], "name": "Browser share" }, {"dummy": null } ], "test": {"formatter": "function(){return \u0027\u0027+ this.point.name +\u0027&lt;\/b&gt;: \u0027+ this.y +\u0027 %\u0027;}" }, "title": {"align": "center", "text": "Your chart title here" }, "tooltip": {"formatter": "function(){return \u0027\u0027+ this.point.name +\u0027&lt;\/b&gt;: \u0027+ this.y +\u0027 %\u0027;}" } }
  </code></pre>
  
  <hr>
  
  <p>I've now found the correct pattern that seems to work and find multiple matches in the string. Posting it here for completion.</p>
  
  <blockquote>
    <p>string pattern = "(\"formatter\": )\"(.<strong>[^\"]*</strong>)\"";</p>
  </blockquote>