Community
    • Login

    Align Questions in One line.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 621 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.
    • Martin MartinM
      Martin Martin
      last edited by

      Hi everyone… hope you can help me. Apologies for my English.

      I got like 1800 questions. Like this:

      Notepad++.png

      As you can see question 295 is in one single line. But question 296 es in two lines. I have a lot of questions like that, like 296. I need all the questions to be in one single line. how can i achieve that?

      Thanks.

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

        @Martin-Martin

        You could use this as a starting point:

        Find: (?-s)^\d+\..+\K\R(?!A\))
        Replace: a single space
        Search mode: Regular expression

        Martin MartinM 2 Replies Last reply Reply Quote 2
        • Martin MartinM
          Martin Martin @Alan Kilborn
          last edited by

          @Alan-Kilborn said in Align Questions in One line.:

          Find: (?-s)^\d+…+\K\R(?!A))
          Replace: a single space
          Search mode: Regular expression

          THANKS A LOT!!! BIG THANKS!!!

          That solved my problem!!!

          1 Reply Last reply Reply Quote 1
          • Martin MartinM
            Martin Martin @Alan Kilborn
            last edited by

            @Alan-Kilborn

            Sorry to bother you again… did you know how to do the same, but for the Answers?

            I mean… I have this format:

            A) XXXXXXXXX
            XXXXXX
            B)XXXXXXXX
            C)XXXXXXXX
            D)XXXXXX
            XXXXXXXX

            I want A and B or whatever answers in the exam to be in 1 line too, like this:

            A)XXXXXX
            B)XXXXX
            C)XXXXXXXXX
            D)XXXXXXXX

            PeterJonesP 1 Reply Last reply Reply Quote 0
            • PeterJonesP
              PeterJones @Martin Martin
              last edited by PeterJones

              @Martin-Martin said in Align Questions in One line.:

              did you know how to do the same, but for the Answers?

              In the regex that @Alan-Kilborn showed, the \d+\. at the beginning means “one or more digits followed by a literal dot character”.

              For requiring it to be one or more letters then an end-parentheses like your answers are, replace that portion of the regex with a regex that means “one or more uppercase letters followed by a literal parentheses”: \u+\) …

              Further, the (?!A\)) says “stop the match once you hit a literal A)” … So the equivalent for the answer would be "stop the match once you hit a different capital(s)-then-paren, and stop if you come across ANSWER: -> (?!\h+\))(?!ANSWER:)

              Those tweaks to the original will work for your new

              ----

              Useful References

              • Please Read Before Posting
              • Template for Search/Replace Questions
              • Formatting Forum Posts
              • Notepad++ Online User Manual: Searching/Regex
              • FAQ: Where to find other regular expressions (regex) documentation
              Martin MartinM 1 Reply Last reply Reply Quote 0
              • Martin MartinM
                Martin Martin @PeterJones
                last edited by Martin Martin

                @PeterJones said in Align Questions in One line.:

                (?!\h+))(?!ANSWER:)

                Sorry I’m new to this. English is not my mother tongue.

                I understood this?:

                Find: (?-s)^\u+…+\K\R(?!\h+))(?!ANSWER:))
                Replace: a single space
                Search mode: Regular expression

                Obviously I did something wrong because it says Invalid Regular Expression.

                I managed to erase some parenthesis but the result was that B options and C options dissapeared or merged in one line… I’m a complete disaster. but i managed to undo actions. Everything is fine, answers are back, but I can’t put them in one line yet.

                PeterJonesP 1 Reply Last reply Reply Quote 0
                • PeterJonesP
                  PeterJones @Martin Martin
                  last edited by PeterJones

                  @Martin-Martin ,

                  You misunderstood on one (the … wasn’t part of the expression: it wasn’t red), and I had a couple of typos (accidentally said \h+ instead of \u+).

                  I guess I should have spelled it all out, and should have tried it before posting.

                  FIND WHAT: (?-s)^\u+\).+\K\R(?!\u\))(?!ANSWER)

                  converts

                  1. Question 1
                  A) A1
                  second line
                  B) two
                  C) three
                  D)four
                  with another line
                  ANSWER
                  2. question two
                  A) A1
                  second line
                  B) two
                  C) three
                  D)four
                  with another line
                  ANSWER
                  

                  to

                  1. Question 1
                  A) A1 second line
                  B) two
                  C) three
                  D)four with another line
                  ANSWER
                  2. question two
                  A) A1 second line
                  B) two
                  C) three
                  D)four with another line
                  ANSWER
                  

                  And if any of your choices are 3 or more lines long, just re-run the regex until it doesn’t make any more changes.

                  Martin MartinM 1 Reply Last reply Reply Quote 1
                  • Martin MartinM
                    Martin Martin @PeterJones
                    last edited by

                    @PeterJones said in Align Questions in One line.:

                    (?-s)^\u+).+\K\R(?!\u))(?!ANSWER)

                    I don’t know how to express gratitude on the internet. But BIG THANKS. YOU SAVED ME A LOT OF TIME.

                    Really. THANK YOU.

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