I've tryied convert a snippet code from C# to Java but without success. My doubt is in Regex
classes.
C# code
string estado = Regex.Match(pagina, "<td width=\"25\" style=\"padding: 2px\">(.*)</td>").Groups[1].Value;
estado = "<label>" + estado + "</label>";
In this code, I declare a string called estado
and search in a another string called pagina
a specific character.
How can I do this Regex
in Java ?
HTML (I simplify the sample because is too big, so I put three dots where don't means so much to me)
<!DOCTYPE html SYSTEM "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Correios</title>
...
<td width="268" style="padding: 2px">Rua Satelite</td>
<td width="140" style="padding: 2px">Caicara</td>
<td width="140" style="padding: 2px">Belo Horizonte</td>
<td width="25" style="padding: 2px">MG</td>
<td width="65" style="padding: 2px">30280-291</td>
</tr></table>
...
I need these <td>
tags, but in Java Code.