Community
    • Login

    Replacement of code (several lines) by only one line

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 3 Posters 2.8k Views 2 Watching
    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.
    • Konrad WielechowskiK Offline
      Konrad Wielechowski
      last edited by

      Hi!

      I would like to replace this code:

      <ul class=“lista2”>
      <li style=“margin-right:auto; margin-left:135”><div style=“width:483px”><p>Są znacznie tańsze niż gdyby były wykonane w całości ze srebra.</p></div></li><!–320–>
      <li style=“margin-right:auto ; margin-left:135”><div style=“width:266px”><p>Są bardziej plastyczne i wytrzymałe. </p></div></li>
      <li style=“margin-right:auto ; margin-left:160px” class=“wciete”><div style=“width:260px”><p style=“font-style:italic ; font-size:15px”>(Czyste srebro jest kruchym metalem.)</p></div></li>
      <li style=“margin-right:auto ; margin-left:135px”><div style=“width:463px”><p>Wizualnie nie różnią się od tych zrobionych z czystego srebra.</p></div></li>
      <li style=“margin-right:auto ; margin-left:135px”><div style=“width:352px”><p>Zachowuje wszelkie właściwości antyalergiczne.</p></div></li>
      <li style=“margin-right:auto ; margin-left:135px”><div style=“width:670px”><p>Warstwa srebra nie wyciera się nawet po bardzo długim czasie i intensywnym użytkowaniu. </p></div></li>
      <li style=“margin-right:auto ; margin-left:160px” class=“wciete”><div style=“width:578px”><p style=“font-style:italic ; font-size:15px”>(W biżuterii posrebrzanej cienką warstwą srebra warstwa ta potrafi się szybko przetrzeć.)</p></div></li>
      <li style=“margin-right:auto ; margin-left:135px”><div style=“width:550px”><p>Znaczny procentowy udział czystego srebra (925) w ogólnej masie wyrobu.</p></div></li>
      </ul>

      by this code:

      <center><img src=“http://krainasrebra.hostinglite.pl/szablon/images/zalety.png”></img></center>

      But when I use function “Search and Replace” and I simply copy and paste the code to replace, notepad doesn’t allow me to input into field more than one line. When I copy and paste I have only first line of code in the field:

      <ul class=“lista2”>

      How to replace the whole code, by only one line of code ?

      Thanks.

      Matt AndersonM 1 Reply Last reply Reply Quote 0
      • Matt AndersonM Offline
        Matt Anderson @Konrad Wielechowski
        last edited by

        @Konrad-Wielechowski

        Try selecting the entire code you want to replace and then use CTRL+H to bring up the search and replace dialog box instead of using copy/paste. Not positive it will work but I’m pretty sure I’ve done it that way before and all of the lines of code were inserted in the search box instead of just the first line. Hope this helps!

        1 Reply Last reply Reply Quote 0
        • Matyáš KrupičkaM Offline
          Matyáš Krupička
          last edited by Matyáš Krupička

          You can do it with regexp or extended search mode

          1st prepare the string for one line by selecting it and replace (search mode extended) in selection
          replace
          \r\n
          with
          \r\n

          Then you will get one line, which you can copy into “find what” and replace (again, search mode extended)with whatever you want.

          IMPORTANT, check first, that you text doesn’t contain backslashes. If it does, you need to escape them by double backslash.
          less IMPORTANT, this example is written in case your file is using dos/windows (CR LF) break type. If it is using other, you need to modify it accordingly. (\r is for CF and \n is for LF).

          **So in your example **

          replace
          <ul class=“lista2”>\r\n<li style=“margin-right:auto; margin-left:135”><div style=“width:483px”><p>Są znacznie tańsze niż gdyby były wykonane w całości ze srebra.</p></div></li><!–320–>\r\n<li style=“margin-right:auto ; margin-left:135”><div style=“width:266px”><p>Są bardziej plastyczne i wytrzymałe. </p></div></li>\r\n<li style=“margin-right:auto ; margin-left:160px” class=“wciete”><div style=“width:260px”><p style=“font-style:italic ; font-size:15px”>(Czyste srebro jest kruchym metalem.)</p></div></li>\r\n<li style=“margin-right:auto ; margin-left:135px”><div style=“width:463px”><p>Wizualnie nie różnią się od tych zrobionych z czystego srebra.</p></div></li>\r\n<li style=“margin-right:auto ; margin-left:135px”><div style=“width:352px”><p>Zachowuje wszelkie właściwości antyalergiczne.</p></div></li>\r\n<li style=“margin-right:auto ; margin-left:135px”><div style=“width:670px”><p>Warstwa srebra nie wyciera się nawet po bardzo długim czasie i intensywnym użytkowaniu. </p></div></li>\r\n<li style=“margin-right:auto ; margin-left:160px” class=“wciete”><div style=“width:578px”><p style=“font-style:italic ; font-size:15px”>(W biżuterii posrebrzanej cienką warstwą srebra warstwa ta potrafi się szybko przetrzeć.)</p></div></li>\r\n<li style=“margin-right:auto ; margin-left:135px”><div style=“width:550px”><p>Znaczny procentowy udział czystego srebra (925) w ogólnej masie wyrobu.</p></div></li>\r\n</ul>

          with
          <center><img src=“http://krainasrebra.hostinglite.pl/szablon/images/zalety.png”></img></center>

          1 Reply Last reply Reply Quote 0
          • Matyáš KrupičkaM Offline
            Matyáš Krupička
            last edited by

            EDIT:

            When preparing one line, replace
            \r\n
            with
            \\r\\n

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors