title: How do I print a Ruby regex variable?
body: <p>How do I print/display just the part of a regular expression that is between the slashes?</p>
  
  <pre><code>irb&gt; re = /\Ahello\z/
  irb&gt; puts "re is /#{re}/"
  </code></pre>
  
  <p>The result is:</p>
  
  <pre><code>re is /(?-mix:\Ahello\z)/
  </code></pre>
  
  <p>Whereas I want:</p>
  
  <pre><code>re is /\Ahello\z/
  </code></pre>
  
  <p>...but not by doing this craziness:</p>
  
  <pre><code>puts "re is /#{re.to_s.gsub( /.*:(.*)\)/, '\1' )}/"
  </code></pre>