How do I split a one liner into mulitple lines with different length?

2. Help
M. Buecher
2013-02-19
2013-03-04
  • M. Buecher
    M. Buecher
    2013-02-19

    I have one file which contains a single one liner (text stream) that contains multiple lines/records.
    Each line holds its full length in the first 5 chars.
    Now I want to add a linebreak behind each line to separate them and get multiple lines.

    Example:
    00009test00011stream00006X0002101234567890ABCDEF

    Wanted result:
    00009test (9 chars: 5+4)
    00011stream (11 chars: 5+6)
    00006X (6 chars: 5+1)
    000210123456789ABCDEF (21 chars: 5+16)

    My idea was to create a macro that...
    #1 positions at home (before char 1 of file)
    #2 copies the first 5 chars into clipboard
    Example: 00009
    #3 goes forward inside current line
    Example: Go to char 00009 in current line
    #4 press enter to separate line, also gets into the line with the remaining text stream
    #5 start over at step #2, leave at step #2 if empty line

    But the goto function of Notepad++ only allows to go to a specific char within the file, not within the current line. Also when recording a macro it records the fixed value 00009 instead of using the actual clipboard content. It seems the macro functionality is just recording GUI clicks/moves via Windows messages with fixed values.

    Are there other ways to get this done within Notepad++? RegEx?

    Thanks in advance
    Maddes

     
    Last edit: M. Buecher 2013-02-19
  • cchris
    cchris
    2013-03-04

    This is definitely a script job. A regex won't parametrise itself with the text it parsees, and, as your last example shows, there doesn't seem to be a wotk around this.

    N++ has plugins supporting the main scriptiong languages - PHP, Python, JavaScript and more.

    CChris