removing \r lines without deleting text



  • 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



  • try:

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



  • sorry i mean: \r\n

    greets pulsar



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



  • @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 **



  • 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



  • 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


  • @Scott-Sumner said:

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

    Thanks for your help Scott :)



  • 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



  • 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



  • 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


Log in to reply