title: Perl one-liner to extract groups of characters
body: <p>I am trying to extract a group of characters with a Perl one-liner, but I have been unsuccessful:</p>
  
  <pre><code>echo "hello_95_.txt" | perl -ne 's/.*([0-9]+).*/\1/'
  </code></pre>
  
  <p>Returns nothing, while I would like it to return <code>95</code>. How can I do this with Perl?</p>
  
  <h1>Update:</h1>
  
  <p>Note that, in contrast to the suggested duplicate, I am interested  in how to do this from the <em>command-line</em>.  Surely this looks like a subtle difference, but it's not straightforward unless you already know how to effectively use Perl one-liners.</p>
  
  <p>Since people are asking, eventually I want to learn to use Perl to write powerful one-liners, but most immediately I need a one-liner to extract consecutive digits from each line in a large text file.</p>