title: Toggle regex options inside a named capture
body: <p>In a regular expression in Ruby you can name a capture using the syntax:</p>
  
  <pre><code>/(?&lt;name&gt;…)/
  </code></pre>
  
  <p>and you can toggle the m/i/x options on/off within a non-capturing group using the syntax:</p>
  
  <pre><code>/(?i:[a-z])/
  </code></pre>
  
  <p>Is there any way to combine the two in a single group?</p>
  
  <hr>
  
  <p>All of these work, but I am wondering if there is a simpler option:</p>
  
  <pre><code>/(?i:(?&lt;name&gt;…))/      # case-insensitive just within the region
  /(?&lt;name&gt;(?i:…))/      # case-insensitive just within the region
  /(?i)(?&lt;name&gt;…)(?-i)/  # case-insensitive turned on, then turned off
  </code></pre>