title: replace a tag with regex
body: <p><img src="https://i.stack.imgur.com/SEjE7.png" alt="enter image description here"></p>
  
  <p>I'm trying to do my homework but regex is new for me and I'm not sure why my code doesn't work. That's what I have to do:</p>
  
  <blockquote>
    <p>Write a program that replaces in a HTML document given as string all the tags <code>&lt;a href=…&gt;…&lt;/a&gt;</code> with corresponding tags <code>[URL href=…]…[/URL]</code>. Read an input, until you receive “end” command. Print the result on the console.</p>
  </blockquote>
  
  <p>I wrote:</p>
  
  <pre><code>Pattern pattern = Pattern.compile("&lt;a href=\"(.)+\"&gt;(.)+&lt;\\/a&gt;");
  input = input.replaceAll(matcher.toString(), "href=" + matcher.group(1) + "]" + matcher.group(2) + "[/URL]");
  </code></pre>
  
  <p>And it throws Exception in thread "main" java.lang.IllegalStateException: </p>
  
  <pre><code>No match found for this input: href="http://softuni.bg"&gt;SoftUni&lt;/a&gt;
  </code></pre>