How to get a second duplicate column

  • Anonymous

    Anonymous - 2013-06-01


    For reasons that I won't go into, I need to do the following
    I have a long list of references (numbers and letters)



    I simply need to add a tab break after each one and insert the same reference to give me

    R587_7AC R587_7AC

    What would be the best way to do this please?


    Sorry but I'm not very good with Notepad ++. I have read the manual a long time ago but I forget things and don't have too much time at work.So I prefer the forum

  • dail8859

    dail8859 - 2013-06-01

    Ah, the power of regular expressions. You can do a Find/Replace in regular expression mode. Use ^(\w+)$ for the "Find" textbox, and \1\t\1 in the "Replace" textbox.

    For a little explanation of ^(\w+)$. The ^ character says find the beginning of a line. Everything in the parenthesis is a group (this being group 1 since it is the first and only group in the expression). \w is any word character, that is A-Z, 0-9, and underscore. The + says find 1 or more consecutive word characters, and finally the $ is the end of a line.

    Using \1\t\1 says replace it with group 1, followed by a tab, and then group one again.

  • Anonymous

    Anonymous - 2013-06-01

    Hello Dali8859

    It worked first time and I was also able to fine my expressions beginning and ending with " and even those in brackets by changing the regex slightly (i'm not good at regexes but I'm getting better)




    THEVENOT Guy - 2013-06-01

    Hi, Safe Tex,

    The Search/Replacement and the explanations, proposed by dail8859, are quite correct and useful, but it's still possible to simplify the regex, in the SEARCH part !

    Just use  .+  in the SEARCH text box and  $0\t$0 in the REPLACEMENT text box

    Explanations :

    .+ represents all the contents of any NON empty line

    $0 represents the totality of the SEARCH string

    Of course, it's the "initial" example and I know, as you said in your last post, that you "customized" your regex afterwards, to suit your proper needs !



    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 :

    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-06-01