• Login
Community
  • Login

Find with regex a particular word between 2 lines

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
6 Posts 3 Posters 370 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.
  • V
    Vasile Caraus
    last edited by Jul 2, 2023, 2:20 PM

    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
    
    W 1 Reply Last reply Jul 2, 2023, 6:43 PM Reply Quote 0
    • W
      wonkawilly @Vasile Caraus
      last edited by wonkawilly Jul 2, 2023, 6:55 PM Jul 2, 2023, 6:43 PM

      @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

      V 1 Reply Last reply Jul 2, 2023, 7:17 PM Reply Quote 0
      • V
        Vasile Caraus @wonkawilly
        last edited by Jul 2, 2023, 7:17 PM

        @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>

        W 1 Reply Last reply Jul 2, 2023, 11:33 PM Reply Quote 0
        • M
          Mark Olson
          last edited by Jul 2, 2023, 7:51 PM

          @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
          • W
            wonkawilly @Vasile Caraus
            last edited by wonkawilly Jul 2, 2023, 11:42 PM Jul 2, 2023, 11:33 PM

            @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.

            V 1 Reply Last reply Jul 3, 2023, 8:17 PM Reply Quote 1
            • V
              Vasile Caraus @wonkawilly
              last edited by Vasile Caraus Jul 3, 2023, 8:22 PM Jul 3, 2023, 8:17 PM

              @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
              3 out of 6
              • First post
                3/6
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors