java - Parsing a String - Http string -


I want to do something like that! So I have been left with the website portion of the string. I was having problems with the quotation in the string.

  ///////////////////// This is what I read in a string. /// & lt; Td width = "118" & gt; & Lt; A href = "research.html" category = "navitist style 10 style 12" & gt; /////// I want to be able to parse it, so I'm left with research.html / I / I sometimes get a string in which: // & lt ; A href = "http: //www.ucalgary ca" class = "style18" & gt; & Lt; Font size = "3" & gt; University of Calgary & lt; / Font & gt; & Lt; / A & gt; & Lt; / Div & gt; // I want to keep http://www.ucalgary.ca with this string   

Whatever I do not always work for every case, I would be thankful to help you !! My code is

  public square parse {public static zero main (string [] args) {string h = "& lt; a href = \" http://www.departmentofmedicine.com/ Policy .htm \ "& gt;"; String url = a [0] .replaceAll ("\" ",", "n", ""); // string value = one [1] .replaceAll ("& lt; / a", ""); System.out.println (url + ""); } Public Fixed int getIndexOf (string str, char c, int n) {int pos = str.indexOf (c, 0); Whereas (n--> 0 & amp; pos! = -1) {pos = str.indexOf (c, pos + 1); } Return status; }}    

I will give Pattern and Mettre a try like this:

  string s = "& lt; a href = \" http: //www.departmentofmedicine.com/policy.htm \ "& gt;"; Pattern p = Pattern.compile (". * Href = \" ([^ \ "] *. * '); Maitre M = P. MATTER (S); If (m.matches ()) {System.out.println (m.group (1)); }    

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -