• Login
Community
  • Login

Replacement of code (several lines) by only one line

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
4 Posts 3 Posters 2.6k 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.
  • K
    Konrad Wielechowski
    last edited by Jul 23, 2016, 3:33 PM

    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.

    M 1 Reply Last reply Jul 24, 2016, 6:42 AM Reply Quote 0
    • M
      Matt Anderson @Konrad Wielechowski
      last edited by Jul 24, 2016, 6:42 AM

      @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
      • M
        Matyáš Krupička
        last edited by Matyáš Krupička Jul 26, 2016, 2:10 PM Jul 26, 2016, 2:08 PM

        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
        • M
          Matyáš Krupička
          last edited by Jul 26, 2016, 2:34 PM

          EDIT:

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

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