title: What's the best way to escape user input for Regular Expressions in MySQL?
body: <p>I'd like to take user input, denoted as $dangerous_string, and use it as part of a RegEx in a MySQL query.</p>
  
  <p>What's the best way to go about doing this?  I want to use the user's string as a literal -- if it contains any characters that mean something in MySQL RegEx, those characters should not actually affect my Regular Expression.</p>
  
  <pre><code>$dangerous_string = $_GET["string"];
  //do something here
  $dangerous_string = what_goes_here($dangerous_string);
  $sql = "SELECT * FROM table WHERE search_column REGEX '" . $mysqli-&gt;real_escape_string("[[:&lt;:]]$dangerous_string") . "'";
  
  //etc....
  </code></pre>