How do I merge data in different lines in notepad++ whatever is between two different dates?



  • How do I merge data in different lines in notepad++ whatever is between two different dates?

    Example -
    "9/23/16, 09:03 - Name A: aadfajlfdjsalfj fasdfasfjalkfjalj afjaljflajf asflajfljljieoeijfhoioij jowjroiwcsojcos wjorjoijsoavaosg

    2742jsogoaj

    9/24/16, 12:05 - Name B: jgaojaegeioie ejgpoapsdfs;
    pajavpoapokads

    askjflkj gkjklgja"

    =======================================================================================

    I want to merge data after the “9/23/16, 09:03 - Name A:” ********** till the words mentioned before 9/24/16, 12:05 - Name B:

    Dates should be always in a new line only like the below matter.

    9/23/16, 09:03 - Name A: aadfajlfdjsalfj fasdfasfjalkfjalj afjaljflajf asflajfljljieoeijfhoioij jowjroiwcsojcos wjorjoijsoavaosg 2742jsogoaj
    9/24/16, 12:05 - Name B: jgaojaegeioie ejgpoapsdfs; pajavpoapokads askjflkj gkjklgja"

    Can anybody give a solution to my question as I have a huge data which is like the above example.



  • @Yusuf-Qureshi

    select the lines and then Edit->Line Operations->Join Lines

    Cheers
    Claudia



  • Thanks a lot for replying… :) but that is what manually I can do and I am aware of that where as I have a huge data and is taking lots and lots of time doing it line by line… I was searching for a command or any sort of short cuts by which I can do it for all complete file…



  • Hello, Yusuf Qureshi,

    As usual, a simple Search/Replacement, in Regular expression mode, is the right way to do ! So :

    • Go back to the very beginning of your file ( CTRL + Origin )

    • Open the Replace dialog ( CTRL + H )

    • In the Find what zone, insert the regex \R+(?!\d\d?/\d\d?/(\d\d)?\d\d)

    • In the Replace with zone, type any character which will replace the deleted EOL characters. It could be :

      • A space character

      • Any separator as, for instance, the | pipe character or a comma, or…

      • Nothing, if you want to join the lines, strictly

    • Select the Regular expression search mode ( IMPORTANT )

    • Click on the Replace All button

    Notes on that S/R :

    • The first part \R+ syntax matches any kind of consecutive EOL characters ( \r\n ) in Windows files, ( \n ) in Unix files or ( \r ) in Mac files

    • The third part \d\d?/\d\d?/(\d\d)?\d\d would match any date, of the form :

      • 1/12/16
      • 23/3/16
      • 10/11/16
      • 1/2/16
      • 1/12/2016
      • 23/3/2016
      • 10/11/2016
      • 1/2/2016
    • That third part is embedded in the syntax (?!.........), which is called a negative look-ahead. This means that an overall match will be true, ONLY IF, right after the EOL character(s), a date, with the above sizes, cannot be found !

    • In that case, the range of consecutive EOL character(s) will be replaced, by any string, typed in the replacement field, even nothing !

    Best Regards,

    guy038

    P.S. :

    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

    We may, also, look for valuable informations, on the sites, below :

    http://www.regular-expressions.info

    http://www.rexegg.com

    http://perldoc.perl.org/perlre.html

    To end with, you may ask, the N++ Community, for infos on any tricky regex that you came across OR for building any tricky regex, for a particular purpose :-))



  • @guy038 you are the best… you just saved my lots of time. Thanks a lot you don’t know how much did you helped me here.

    Thankyou
    Thankyou
    Thankyou


Log in to reply