0

I will describe my problem in a given HTML format:

<Doc>
  <test>
    <tr>
      <td>
        <p>Test 1</p>
      </td>
      <td>
        <p>Test 2</p>
      </td>
    </tr>
    <tr>
      <td>
        <p>75%</p>
      </td>
      <td>
        <p>86%</p>
      </td>
    </tr>
  </test>
</Doc>

Now as you noticed there are 2 <tr></tr> tags, i want to change/replace, ONLY the FIRST <tr></tr> tag (that contains Test 1 and Test 2) to "<th></th>". BTW, there are several occurrences for <test></test> within the <Doc></Doc> tag and several occurrences for <tr></tr> within the <test></test> tags like as shown below:

<Doc>
  <test>
    <tr>
      <td>
        <p>Quiz 1</p>
      </td>
      <td>
        <p>Quiz 2</p>
      </td>
      <td>
        <p>Exam 1</p>
      </td>
    </tr>
    <tr>
      <td>
        <p>24 out of 50</p>
      </td>
      <td>
        <p>16 out of 50</p>
      </td>
      <td>
        <p>77/100</p>
      </td>
    </tr>
  </test>
</Doc>

So far i've got this: (<table>\s+<tr>\s+)(<td>)\s+<p>.*</p>\s+(</td>) i don't know how to get the right mix as i am new to regex. Sorry for my english.

Lucas
  • 5
  • 3

0 Answers0