I have a large HTML String which contains some lines before the actual HTML code which are empty HTML and are not actually needed.
messageContent will contain something like:
<td width="35"><br /> </td>
<td width="1"><br /> </td>
<td width="18"><br /> </td>
<td width="101"><br /> </td>
<td width="7"><br /> </td>
<td rowspan="21" colspan="16" width="689">Geachte heer/mevrouw,<br /> <br /> Wij hebben uw inzending ontvangen en gecontroleerd. Hierbij het verslag van de controle.<br /> <br />
I want to remove/replace everything before the line which contains 'Geachte', ' heer' and ' mevrouw'.
As output I would like to keep only:
<td rowspan="21" colspan="16" width="689">Geachte heer/mevrouw,<br /> <br /> Wij hebben uw inzending ontvangen en gecontroleerd. Hierbij het verslag van de controle.<br /> <br />
I thought I would use a BufferedReader to loop trough the text line by line:
try {
reader = new BufferedReader(
new StringReader(messageContent));
} catch (Exception failed) { }
try {
while ((string = reader.readLine()) != null) {
if ((string.length() > 0) && (string.contains("Geachte"))) {
//remove all lines before this string
}
}
} catch (IOException e) { }
How do I achieve this?