How to: Search for line and move up to end of previous line?

RyoOkutani
2013-09-06
2013-09-12
  • RyoOkutani

    RyoOkutani - 2013-09-06

    Firstly - apologies if this is in the wrong section, this is my very first post.

    Question:
    How do I get Notepad++ to search for lines starting with a certain text, then shift a set section up to the end of the previous line? (or if Notepad++ is unable to do this, perhaps a suggestion on a different app that can?)

    Could i somehow get it to search for "OMEGA***\" and do the below? (as there will be multiple such lines where the numbers change but format stays the same)

    Example below:

    Before
    Firstline
    OMEGA\00\001\RM.001.00001_000{1-5}.tif

    After
    FirstlineOMEGA\00\001\ RM.001.00001_000{1-5}.tif

    Thanks in Advance!

     
    Last edit: RyoOkutani 2013-09-06
  • cchris

    cchris - 2013-09-08

    Search: \R(OMEGA.*)
    Replace with: \1
    Select "Regular expressions".
    Uncheck ". matches newline"

    CChris

     
    • RyoOkutani

      RyoOkutani - 2013-09-09

      HI Cchris,

      thanks for your response however that didnt seem to work? I just get the error "Replace: no occurrence found."

       
  • RyoOkutani

    RyoOkutani - 2013-09-09

    Just further to the above, i want to shift the "OMEGA\00\001\" (numbers will change but format stays the same) section up a line and at the end so that the next line starts with RM.001.*

     
    Last edit: RyoOkutani 2013-09-09
  • THEVENOT Guy

    THEVENOT Guy - 2013-09-11

    Hello, RyoOkutani,

    I don't understand why it doesn't work with you, because the cchris's search regular expression seems OK, regarding your very first post !

    Of course, you must use an Unicode version of Notepad++, since the 6.0 version or above !

    With the additional information you gave in your last post, I would say :

    SEARCH : \R(OMEGA.*?)RM
    REPLACE : \1\r\nRM

    with the same options, given by cchris

    Just for info :

    • \R stands for any EOL ( Windows \r\n, Unix \n or Old Mac \r ), only in search part
    • (OMEGA.*?) represents ALL the characters between the previous EOL and the first occurrence of RM, excluded, and it is stored, as group 1, to be recalled as \1, in the replacement part
    • \r\n is the standard Windows EOL, in the replacement part

    Best regards,

    guy038

    P.S. :

    You will find good documentation, about the new Perl Common Regular Expressions (PCRE), used by N++, since the 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 concerns the syntax of regular expressions in SEARCH

    The SECOND link concerns the syntax of regular expressions in REPLACEMENT

     
    Last edit: THEVENOT Guy 2013-09-11
    • RyoOkutani

      RyoOkutani - 2013-09-12

      Ahhh brilliant, thanks guy038.

      This has worked very well!

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks