title: Java replace content in a link
body: <p>I need to read the html of a webpage, then find the links and images, then rename the links and images, what i have done</p>
  
  <pre><code>reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), 'UTF-8'));  
  String line;  
  while ((line = reader.readLine()) != null) { 
      regex = "&lt;a[^&gt;]*href=(\"([^\"]*)\"|\'([^\']*)\'|([^\\s&gt;]*))[^&gt;]*&gt;(.*?)&lt;/a&gt;";  
      final Pattern pa = Pattern.compile(regex, Pattern.DOTALL);  
      final Matcher ma = pa.matcher(s);  
      if(ma.find()){  
          string newlink=path+"1-2.html";
          //replace the link in href with newlink, how can i do this?
      }  
      html.append(line).append("/r/n");  
  }  
  </code></pre>
  
  <p>how can i do the comment part</p>