Community
    • Login

    Regex: I cannot find and replace unless I copy to another file

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 171 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.
    • Neculai I. FantanaruN
      Neculai I. Fantanaru
      last edited by

      I have this regex, very good:

      ([^>])(\r\n)(<p class="mb-40px">)

      I have an html page, UTF-8-bom, or simple UTF-8. My problem is that in the actual html, the regex cannot find anything on search.

      The strange thing is that, if I copy all the html content into another empty files, txt or html, the Regex works great and succeeded to make the Find and Replace.

      <p class="mb-40px">En 1526, Buonarrotipropuso un nuevo proyecto a los Della Rovere (el cuarto), esta vezrealmente como una tumba mural; los herederos respondieron amenazándole con una demanda judicial. Finalmente, en 1532, se llegó a un nuevo acuerdo sobre la base de un nuevoproyecto ( el quinto), que manteníala estructura arquitectónica del de 1516(el tercero), aunque simplificaba ladecoración, que para el gusto de laépoca era ya excesivamentedetallista y anticuada. Los dosesclavos realizados en 1513-14 eran inútilesahora, Miguel Ángel los regaló a RobertoStrozzi, un noble florentino amigo suyo, oponente político de los Médici,que vivía entonces (tras la última restauración de los Médici) en Roma. Strozzia su vez los regaló diez años más tarde a Francisco I de Francia , y así escomo tras haber pasado por varias colecciones francesas se incorporaron a comienzos del siglo XIX, a las coleccionesdel Louvre .</p>
      <p class="mb-40px">Decisiva también, de
      <p class="mb-40px">otro modo, fue la oportunidad de
      <p class="mb-40px">adquirir lo que habían de ser dos pilares
      <p class="mb-40px">fundamentales de su formación intelectual: 
      <p class="mb-40px">latín y prácticamente ninguno del griego
      <p class="mb-40px">anotadas, eran objeto de comentario cotidiano en la Apolo.</p>
      

      Why does this happen? Why do I have to copy all the code to another file, for that Regex to succeed in Find and Replace?

      Terry RT 1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R @Neculai I. Fantanaru
        last edited by

        @Neculai-I-Fantanaru said in Regex: I cannot find and replace unless I copy to another file:

        (\r\n)

        \r\n is for a windows file. As your html may have come from a linux host it may not use exactly that sequence. I think \r is linux and \n is Mac. You could use \R which means all types.

        Look at the original file in Notepad++ and use View, Show Symbol and select either End of Line or Show All Characters to confirm my prognosis.

        Terry

        Mark OlsonM 1 Reply Last reply Reply Quote 1
        • Mark OlsonM
          Mark Olson @Terry R
          last edited by

          @Terry-R said in Regex: I cannot find and replace unless I copy to another file:

          I think \r is linux and \n is Mac

          other way around, \n is Linux (and also cmd and Powershell) and \r is Mac.

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