title: How can I extract the HREF value from an HTML link?
body: <p>My text file contains 2 lines:</p>
  
  <pre><code>&lt;IMG SRC="/icons/folder.gif" ALT="[DIR]"&gt; &lt;A HREF="yahoo.com.jp/"&gt;yahoo.com.jp/&lt;/A&gt;
  &lt;/PRE&gt;&lt;HR&gt;
  </code></pre>
  
  <p>In my Perl script, I have:</p>
  
  <pre><code>my $String =~ /.*(HREF=")(.*)("&gt;)/;
  print "$2";
  </code></pre>
  
  <p>and my output is the following:</p>
  
  <pre><code>Output 1: yahoo.com.jp
  
  Output 2: &gt;&lt;HR&gt;
  </code></pre>
  
  <p>What I am trying to achieve is have my Perl script automatically extract the string inside the <code>&lt;A Href=""&gt;</code></p>
  
  <p>As I am very new to regex, I want to ask if my regex is a badly formed one? If so can someone provide some suggestion to make it look nicer?</p>
  
  <p>Secondly, I do not know why my second output is <code>"&gt;&lt;HR&gt;"</code>, I thought the expected behavior is that output2 will be skipped since it does not contain HREF=". Obviously I am very wrong.</p>
  
  <p>Thanks for the help.</p>