title: Pattern match on /xxx/xxx/xxx
body: <p>I have</p>
  
  <pre><code>$w="/fold1/fold2/qwerty.h"
  </code></pre>
  
  <p>I want to cut /qwerty.h and get /fold1/fold2</p>
  
  <p>I tried </p>
  
  <pre><code>$w=~s/\/.+\.h\z//; and $w=~s/\/.+?\.h\z//;
  </code></pre>
  
  <p>but those remove whole string.</p>
  
  <pre><code>$w=~s/\/\w+\.h\z//;
  </code></pre>
  
  <p>works but  suppose I have qwe\rty.h instead of qwerty.h. That won't work again.</p>