Help with editing a file



  • Hello, I am working on something and I need to be able to turn a file like this:
    Banana
    Apple
    Mango
    Pear

    Into this:
    Banana-Banana
    Banana-Banana1
    Banana-Banana2
    Banana-Banana3
    Banana-Banana123
    Apple-Apple
    Apple-Apple1
    Apple-Apple2
    (continuing down)

    You get the point. Anyways, is there any way to do this in notepad++? A script or plugin I could download? Any help would be greatly appreciated.



  • @JBlack788

    well it depends on how complex it goes.
    given
    Banana
    Apple
    Mango
    Pear

    and using regular expressions like

    find what: ^(.+)$
    replace with: \1-\1\r\n\1-\11\r\n\1-\12\r\n\1-\13\r\n\1-\1123
    

    would result in

    Banana-Banana
    Banana-Banana1
    Banana-Banana2
    Banana-Banana3
    Banana-Banana123
    Apple-Apple
    Apple-Apple1
    Apple-Apple2
    Apple-Apple3
    Apple-Apple123
    Mango-Mango
    Mango-Mango1
    Mango-Mango2
    Mango-Mango3
    Mango-Mango123
    Pear-Pear
    Pear-Pear1
    Pear-Pear2
    Pear-Pear3
    Pear-Pear123

    \1 = what was found in the line
    \r\n = carriage return new line feed on windows

    Cheers
    Claudia



  • Thank you so much! This helped a great deal.


Log in to reply