Community
    • Login

    removing \r lines without deleting text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    11 Posts 4 Posters 15.5k 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.
    • Maureen HiltonM
      Maureen Hilton
      last edited by

      Help please
      I want to put everything after “?” that is lower case and on a new line back onto the first line.
      e.g

      “What do you mean?
      said Mary”

      I can search ok: \r\r [a-z]
      It is the REPLACE Expression that I am having trouble with. it puts the second line back to the first line after the “?” but misses out the “s” in said

      e.g.,
      "What do you mean? aid Mary

      I am using “” to replace or \1

      Thanks

      Maureen HiltonM 1 Reply Last reply Reply Quote 0
      • pulsar-deP
        pulsar-de
        last edited by

        try:

        search: \n\r
        replace: leave empty or add a whitespace, what you prefer…

        1 Reply Last reply Reply Quote 0
        • pulsar-deP
          pulsar-de
          last edited by

          sorry i mean: \r\n

          greets pulsar

          1 Reply Last reply Reply Quote 0
          • Maureen HiltonM
            Maureen Hilton
            last edited by

            Thanks but that would then move all lines.I just want to move lines that start with a lower case.

            1 Reply Last reply Reply Quote 0
            • Maureen HiltonM
              Maureen Hilton @Maureen Hilton
              last edited by

              @Maureen-Hilton said:

              Help please
              I want to put everything after “?” that is lower case and on a new line back onto the first line.
              e.g

              “What do you mean?
              said Mary”

              I can search ok: \r\r [a-z]
              It is the REPLACE Expression that I am having trouble with. it puts the second line back to the first line after the “?” but misses out the “s” in said

              e.g.,
              "What do you mean? aid Mary

              I am using “” to replace or \1

              Thanks

              **I want to move only the lines that start with lower case **

              1 Reply Last reply Reply Quote 0
              • Scott SumnerS
                Scott Sumner
                last edited by

                I had luck with your test data and the following, but probably without some more example text to process it won’t be quite right:

                Find what: (?-i)?(\R([a-z]))
                Replace with: ? \2

                1 Reply Last reply Reply Quote 0
                • Scott SumnerS
                  Scott Sumner
                  last edited by

                  Ugh, as plaintext it screwed up my strings…let me try again as a code block:

                    Find what:  (?-i)\?(\R([a-z]))
                    Replace with:  ? \2
                  
                  1 Reply Last reply Reply Quote 0
                  • Maureen HiltonM
                    Maureen Hilton
                    last edited by

                    @Scott-Sumner said:

                    Find what: (?-i)?(\R([a-z]))
                    Replace with: ? \2

                    Thanks for your help Scott :)

                    1 Reply Last reply Reply Quote 0
                    • guy038G
                      guy038
                      last edited by guy038

                      Hello Maureen and Scott,

                      Scott, we can even shorten your S/R in :

                      SEARCH (?-i)\?\R([a-z])

                      REPLACE ? \1, with a space between the ? and the back-reference \1


                      Maureen, an other S/R, using the Look-Around feature would be :

                      SEARCH (?-i)\?\R(?=[a-z])

                      REPLACE ? , with a space AFTER the ?

                      This second search regex look for an interrogation mark, with the End of Line character(s), ONLY IF an lowercase letter begins the next line. However, this second syntax is not as simple as Scott’s one !

                      Remember that:

                      • The \R syntax means, among other things, any kind of normal End of Line : \r\n or \n or \r

                      • The interrogation mark, as it’s a special regex character, must be escaped \?, in the search part, to be searched, literally

                      Best Regards

                      guy038

                      1 Reply Last reply Reply Quote 0
                      • Maureen HiltonM
                        Maureen Hilton
                        last edited by

                        Hi Guy
                        Thanks for your reply. Unfortunately I do not have a “Look-Around” feature on my Notepad ++. I have tried to research it and can find no reference to this. Maybe we have different versions of Notepad ++.

                        Thanks

                        1 Reply Last reply Reply Quote 0
                        • guy038G
                          guy038
                          last edited by guy038

                          Hi, Maureen,

                          To use the very powerful regex search feature, with the PERL syntax, you, absolutely, need an Unicode Notepad++ version >= 6.0

                          To get your version number, just, hit the F1 key, when a N++ session is opened

                          As for me, I try to “follow” the different versions, to reply, on that forum, too. So, I use ( one at a time, I’m careful ! ) any portable version, like an old Ansi 5.9.8 version, an Unicode 6.4.5 version, a 6.7.9 version and the last v6.8 version.


                          You’ll find good documentation, about the new Boost C++ Regex library, v1.55.0 ( similar to the PERL Regular Common Expressions, v1.48.0 ), used by Notepad++, since its 6.0 version, at the TWO addresses below :

                          http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html

                          http://www.boost.org/doc/libs/1_48_0/libs/regex/doc/html/boost_regex/format/boost_format_syntax.html

                          • The FIRST link explains the syntax, of regular expressions, in the SEARCH part

                          • The SECOND link explains the syntax, of regular expressions, in the REPLACEMENT part


                          And, if you want, preferably, a general documentation on Notepad++, refer to my post, at the address below :

                          https://notepad-plus-plus.org/community/topic/40/real-help-wanted/3

                          Good reading !

                          Cheers,

                          guy038

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