Community
    • Login

    Find with regex a particular word between 2 lines

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    6 Posts 3 Posters 353 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.
    • Vasile CarausV
      Vasile Caraus
      last edited by

      Find with regex a particular word between 2 lines. For example I have this text:

      <tr>
                  <td><h1 class="den_articol" itemprop="name">Your Mirror</h1></td>
                </tr>
                <tr>
                  <td class="text_dreapta">On Septembrie 05, 2017</td>
                </tr>
              </table>
      <sony>
      <p class="text_obisnuit"><span class="text_obisnuit2">* Not&#259;:</span> <a href="watch?v=IB4P5t3JGlg" target="_new">Simply Red - Your Mirror</a></p>
          </div>
          <p align="justify" class="text_obisnuit style3">&nbsp;</p>
      

      The Ouput must be:

      <sony>
      

      My regex formula doesn’t work:

      </table>([\s\S]*?)<p class="text_obisnuit">|\1
      
      wonkawillyW 1 Reply Last reply Reply Quote 0
      • wonkawillyW
        wonkawilly @Vasile Caraus
        last edited by wonkawilly

        @Vasile-Caraus

        I am not sure I understand the question the right way, so I will try to go with the following hypothesis:
        can’t you just type

        <sony>
        

        into the Find field without the need of matching regex at all?

        or perhaps:

        type in Find

        </table>\r\n(<.*>)\r\n<p class="text_obisnuit">
        

        And in Replace:

        \1
        

        In this case of course bulletting the option to mach Regex, but not the .(point) checkbox?

        0bfebea2-adc0-4164-98da-cdbf0fd010d7-image.png

        Vasile CarausV 1 Reply Last reply Reply Quote 0
        • Vasile CarausV
          Vasile Caraus @wonkawilly
          last edited by

          @wonkawilly said in Find with regex a particular word between 2 lines:

          </table>\r\n(<.*>)\r\n<p class=“text_obisnuit”>

          doesn’t work. Regex must find only <sony>

          wonkawillyW 1 Reply Last reply Reply Quote 0
          • Mark OlsonM
            Mark Olson
            last edited by

            @Vasile-Caraus
            You have only given one example for people to go off of. In order for anyone to give you robust advice that doesn’t fail on all sorts of corner cases, you should:

            1. Provide at least two examples
            2. Preferably give at least one example that contains <sony> but should not be matched
            3. Consider simplifying your examples to remove nonessential details that will confuse your would-be helpers

            Doing this isn’t just considerate of other people’s time, it’s also more useful to you in the long run because the solution that other people provide may be simpler and more targeted.

            1 Reply Last reply Reply Quote 1
            • wonkawillyW
              wonkawilly @Vasile Caraus
              last edited by wonkawilly

              @Vasile-Caraus said in Find with regex a particular word between 2 lines:

              @wonkawilly said in Find with regex a particular word between 2 lines:

              </table>\r\n(<.*>)\r\n<p class=“text_obisnuit”>

              doesn’t work. Regex must find only <sony>

              Can’t you just type

              <sony>
              

              in Find textbox?

              490d151e-5e06-4188-868b-4e1ccafa213c-image.png

              9df77fca-2b21-4d93-bc81-792de48a8ea7-image.png

              As you can see you don’t even need to mach regex for what you are asking for at the moment. If I am making a mistake than perhaps I need more help from you to better understand your needs. Please specify more details.

              Vasile CarausV 1 Reply Last reply Reply Quote 1
              • Vasile CarausV
                Vasile Caraus @wonkawilly
                last edited by Vasile Caraus

                @wonkawilly I need a regex, because I wanna FIND and REPLACE in several html files…

                I find a solution, super

                FIND: </table>\r\n\K(<.*>)|K\r\n<p class="text_obisnuit">

                interesting is that I used K instead of \K

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors