Bobby
Bobby

Reputation: 1595

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

Upvotes: 1

Views: 860

Answers (1)

Federico Piazza
Federico Piazza

Reputation: 31045

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

Upvotes: 2

Related Questions