-2

Im trying to made a regex , but i waste a lot of time and cannot be sucessufully, Here is my input and output expected.

Input:

 <table>
 <tr>
     <td colspan="4" class="fundo_subtitulo">MAX 250</td>
 </tr>
 <tr>
   ANY DATA
 </tr>
 <tr>
   ANY DATA
 </tr>
 <tr>
    <td>MAX 400</td>
 </tr>
 <tr>
   ANY DATA
 </tr>

<table>

Expected Output

find()

     <tr>
       <td colspan="4" class="fundo_subtitulo">MAX 250</td>
     </tr>
     <tr>
       ANY DATA
     </tr>
     <tr>
       ANY DATA
     </tr>

next

     <tr>
        <td>MAX 400</td>
     </tr>
     <tr>
       ANY DATA
     </tr>

Conditions: - Word start with MAX.

Makoton
  • 443
  • 3
  • 14

1 Answers1

1

Try This:

Pattern regex = Pattern.compile("<tr>\\s+<td colspan=\".*?\" class=\".*?\">MAX \\d+</td>\\s+</tr>");

DEMO: http://fiddle.re/z77dp

Pedro Lobito
  • 94,083
  • 31
  • 258
  • 268