Search code examples
regextextwrangler

Regular expression to duplicate each line, add separator, prefix


I would like to have a regular expression that I can use in TextWrangler. I've read that substituting for \n+ will allow me to add the suffix but I do not know how to duplicate and add the separator.

Input:

A
B
C

Output

A_A_suffix
B_B_suffix
C_C_suffix

Solution

  • I cannot confirm about TextWrangler right now since don't have my mac, but you can use this regex which will work on Notepad++ and Sublime:

    (.+)
    

    With this replacement string:

    $1_$1_suffix
    

    Working demo