title: PHP regex fetch part of string?
body: <p>Consider we have a string (which is MySQL Error message) as following:</p>
  
  <blockquote>
    <p>Data truncated for column 'sam_office_balance' at row 1</p>
  </blockquote>
  
  <p>Now I need the part in single quotes as:</p>
  
  <blockquote>
    <p>Sam Office Balance</p>
  </blockquote>
  
  <pre><code>$errorMessage = "Data truncated for column 'sam_office_balance' at row 1";
  // do smthing
  echo $message; //  Should print "Sam Office Balance"
  </code></pre>
  
  <p><strong>What could be the best possible way to this?</strong></p>
  
  <p>My Solution  </p>
  
  <pre><code>private function sqlErrorMessage($message){
  
        //My SQL DataType Error
        $error_string_1 = "Data truncated for column '";
        $error_string_2 = "' at row";
        $pos_error_string_1 = strpos($message, $error_string_1);
        $pos_error_string_2 = strpos($message, $error_string_2);
        if(gettype($pos_error_string_1) != "boolean" &amp;&amp; gettype($pos_error_string_2) != "boolean"){
            $pos_error_string_1 += strlen($error_string_1);
            $errorColumn = substr($message, $pos_error_string_1, $pos_error_string_2 - $pos_error_string_1);
            $errorMessage = $this-&gt;uc_w($errorColumn)." has invalid data.";
            return $errorMessage;
        }
  
        return $message;
      }
  </code></pre>
  
  <blockquote>
    <p><strong>Language: PHP</strong></p>
    
    <p><strong>Technique:</strong> <em>Anything with minimum lines of code.</em></p>
  </blockquote>