Monday 15 February 2010

java - How to extract a matched substring from a String matching a pattern? -


I am reading one of the following patterns:

  ^ < . * & Gt ;. * & Lt; / Td> $ ^ & Lt ;. * & Gt; & Lt ;. * & Gt ;. & Lt; / A & gt; & Lt; / Td> $   

Example: & lt; Td now open valize = "top" class = "style1" & gt; Manhattan & lt; / Td> & Lt; Td abrop valvin = "top" class = "style1" & gt; & Lt; A & gt; New York & lt; / A & gt; & Lt; / Td>

I want to read Manhattan and new york

how can I write 2 Pattern.complie () Am the methods in the same program? Matches () always gives the correct for my input lines, but after this how can I do substrings to remove Manhattan and New York ? Any suggestions would be of great help thanks. Use regular expression like

:

  last pattern pattern = Pattern.compile ("& lt; td> (+). & Lt ;? / td & gt;");    

No comments:

Post a Comment