Community
    • Login

    Replace all spaces with a dash (-) but with a certain limit !

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    9 Posts 3 Posters 1.3k 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.
    • Antoine GautierA
      Antoine Gautier
      last edited by

      Hello,

      I would like to apply a change to a list containing several lines, by changing Space between words with a dash of (-) without touching
      the rest of the words after (/).

      1. Word1 word2 word3 word4 / word5 word6 word7 word8…
      2. Test1 test2 test3 test4 / test5 test6 test7 test8…

      etc. (Hundreds of lines with different words)

      by

      1. Word1-word2-word3-word4 / word5 word6 word7 word8…
      2. Test1-test2-test3-test4 / test5 test6 test7 test8…
        etc.

      Thank you in advance for your help.

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Antoine Gautier
        last edited by

        @Antoine-Gautier

        Try a Regular Expression replacement, searching for (?-s) (?=.*? /) and replacing with -.

        1 Reply Last reply Reply Quote 2
        • Antoine GautierA
          Antoine Gautier
          last edited by

          @Alan-Kilborn said in Replace all spaces with a dash (-) but with a certain limit !:

          (?-s) (?=.*? /)

          Thank you so much. It works very, very well ! :)

          Alan KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @Antoine Gautier
            last edited by

            @Antoine-Gautier

            You’ve asked a few questions on the Community forum now. Here’s one for you: Do you see why what I gave you works?

            Antoine GautierA 1 Reply Last reply Reply Quote 1
            • Antoine GautierA
              Antoine Gautier @Alan Kilborn
              last edited by

              @Alan-Kilborn

              Yes, most of the questions I ask on forum, you always find me beautiful solutions, and that helped me too much, and thank you so so much for your support.

              1 Reply Last reply Reply Quote 1
              • PeterJonesP
                PeterJones
                last edited by

                @Antoine-Gautier ,

                I doubt he was fishing for another thank-you, though that was kind of you. :-)

                What we really like to see is that the people we are helping are learning from our help, otherwise it makes us less eager to help an individual.

                As a learning exercise, I suggest you trying to explain to us what the individual components of Alan’s regex are doing, and why that solves your problem.

                If you need help, you can reference the official Notepad++ searching-using-regular-expressions docs, and maybe this forum’s regex FAQ.

                Do your best trying to explain them. If you don’t understand what they are doing, give it a stab, and then ask us for clarification.

                Antoine GautierA 1 Reply Last reply Reply Quote 2
                • Antoine GautierA
                  Antoine Gautier @PeterJones
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • Antoine GautierA
                    Antoine Gautier
                    last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • Antoine GautierA
                      Antoine Gautier
                      last edited by

                      this lesson is well understood :)

                      I’m an amateur in website creation, and I have several pages under different names, that I have to put dashes (-) instead of Space and at the end of each line before the / I’ll add extension .html and the rest after (/) is the title of each page.

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