Notepad++ Problem with sorting lines



  • Hi,
    I have this line:

    Line1-10 - Art
    Line11-20 - Biology
    Line21-30 - Film
    Line31-40 - Geography
    Line41-50 - History
    Line51-60 - IT
    Line61-70 - Science
    Line71-80 - Sport

    This is what I need:

    Line1 - Art
    Line2 - Biology
    Line3 - Film
    Line4 - Geography
    Line5 - History
    Line6 - IT
    Line7 - Science
    Line8 - Sport
    Line9 - Art
    Line10 - Biology
    .
    .
    .
    .
    etc.



  • @John-Destiny

    I would do:

    Find: ^Line\d+-\d+
    Replace: Line
    Search mode: Reg Expression

    Then, follow that up with inserting a column of ascending digits (see the Column Editor on the View menu).



  • @John-Destiny

    yes, @Alan-Kilborn 's suggestion seems to be the best and easiest way to do so.

    if you need help on the column editor:
    once you’ve run alan’s regex with “replace all”, hold the [alt] key and mark (draw) a cursor-line from the end of the first word Line to the end of the last word Line like shown at the screenshot below.

    Imgur

    then open column editor, select number to insert, with initial number 1 and increase by 1, and hit ok.

    Imgur

    after that, you list will look like this.
    Imgur



  • If you have a lot of lines, you may end up with space(s) between Line and the (first) number. Use the following to remove those:

    Find ^Line\h+(?=\d)
    Replace Line
    Again, search mode is Reg Exp


Log in to reply