title: Howto replace a string containing a dollar character for mysql with RegularExpressions?
body: <p>I try to replace a value for a MySQL INSERT INTO string. This value contains a $ character at the begin and at the end. The $-character at the end and the closing '-Character get lost during the regex.Replace</p>
  
  <p>This is my VB.NET code:</p>
  
  <pre><code>    Dim RawString As String = "$ Million's of Dollar Company $"
      Dim EscapedValue As String = MySql.Data.MySqlClient.MySqlHelper.EscapeString(RawString)
  
      Dim mySQLCommand As String = "INSERT INTO `companies` (`name`, `contact`) VALUES (@name, @contact)"
  
      Dim pattern As String = "@name"
      Dim replacement As String = "'" + EscapedValue + "'"
      Dim regex = New System.Text.RegularExpressions.Regex(pattern)
  
      mySQLCommand = regex.Replace(mySQLCommand, replacement)
  </code></pre>
  
  <p><br><br>
  The expected result is:</p>
  
  <pre><code>"INSERT INTO `companies` (`name`, `contact`) VALUES ('$ Million\'s of Dollar Company $', @contact)"
  </code></pre>
  
  <p><br><br>
  Do you know the reason, why I get this wrong result (missing $' at the end of the first value?)</p>
  
  <pre><code>"INSERT INTO `companies` (`name`, `contact`) VALUES ('$ Million\'s of Dollar Company , @contact), @contact)"
  </code></pre>
  
  <p>How can I fix that?</p>