• Login
Community
  • Login

How to search only the columns of first row in <table>

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
5 Posts 3 Posters 512 Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    Paramesh Paramesh
    last edited by Aug 18, 2024, 1:44 AM

    I need to replace the <td> of only the first row <tr> with <th> in all the tables is there any options to do by using regular expression for instance,

    <tbody>
    <tr><td>aaa</td><td>bbb</td></tr>
    <tr><td>111</td><td>222</td></tr>
    <tr><td>3333</td><td>333</td></tr>
    </tbody>

    in this scenario i need in all tables to replace the first row <td> and </td> should be replaced with <th> and </th> could any one help me out.

    C 1 Reply Last reply Aug 18, 2024, 5:54 AM Reply Quote -1
    • C
      Coises @Paramesh Paramesh
      last edited by Aug 18, 2024, 5:54 AM

      @Paramesh-Paramesh

      You appear to be new here, so I’m going to assume you didn’t know this:

      Posting the same thing three times — once in an unrelated thread, and once with @ callouts to a couple of regulars — is very rude. It won’t help you get answers. This doesn’t just apply here. Any community of users (like this one) won’t appreciate it. We’re just people, like you, who come here looking for help and giving back when we can. No hard feelings, but… don’t do that.

      Now, to your question:

      There’s a FAQ that can help you do this using only standard Notepad++ features:
      https://community.notepad-plus-plus.org/topic/22690/generic-regex-replacing-in-a-specific-zone-of-text

      A second way to do this would be to use a feature of my Columns++ plugin, which you can install from Plugins | Plugins Admin…. After installing:

      First, with nothing selected, open Search… from the Columns++ menu.

      Next, select Search Mode: Regular expression, enter this:
      <tbody[\s\S]*?</tr
      in the Find what box, click the arrow to the right of the Count button and choose Select All.

      At this point, you should see a yellow(ish) region indicator covering the entire file, and a grey selection indication covering each string from <tbody to the next </tr. Click the Set button in the dialog. You’ll see the yellow region indication change to match the selection.

      Now enter:
      Find what : (</?)td
      Replace with : \1th
      and click the Replace All button.

      That should make the changes you need. You can then close the dialog.

      P 1 Reply Last reply Aug 18, 2024, 1:00 PM Reply Quote 5
      • P
        Paramesh Paramesh @Coises
        last edited by Aug 18, 2024, 1:00 PM

        @Coises Thanks a lot, I have tried as you mentioned it worked fine on Individual files.

        But, I have 1576 xml files in all files this changes has to be applied. Is this can be done??

        P C 2 Replies Last reply Aug 18, 2024, 1:47 PM Reply Quote 0
        • P
          PeterJones @Paramesh Paramesh
          last edited by Aug 18, 2024, 1:47 PM

          @Paramesh-Paramesh ,

          BTW, next time, have some patience. You asked the same question in three separate posts in about an hour – in two separate topics you created, plus a reply to a completely unrelated discussion. That is what’s known as a violation of forum etiquette. Don’t do that again.

          I deleted the others, since this is the one that got a reply.

          1 Reply Last reply Reply Quote 3
          • C
            Coises @Paramesh Paramesh
            last edited by Aug 18, 2024, 5:33 PM

            @Paramesh-Paramesh said in How to search only the columns of first row in <table>:

            But, I have 1576 xml files in all files this changes has to be applied. Is this can be done??

            The second method I suggested, using Columns++, only works one file at a time.

            The first method, explained in the FAQ I linked, can be used for multiple files by using Search | Find in FIles (or, equivalently, by switching to the Find in Files tab in the Replace dialog).

            I strongly suggest that you make a copy of the folder containing these files and work on the copy first, as you won’t be able to use undo on multiple files if something goes wrong. Try to follow the FAQ, look at the relevant sections of the online manual , and see what you can work out.

            You might need more help, and it’s OK to ask… after you try your best on your own first and can show us what you’re trying and what isn’t working.

            1 Reply Last reply Reply Quote 4
            2 out of 5
            • First post
              2/5
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors