1

I have a text file that looks something like this:

,'','a','bc','def','ghi','lmn','op','qr','stu'

I'm trying to replace groups of 5 with the match and a line break for easy readability. So, I'm trying to do a regex match and replace.

Find What: ([\,]+[\']+[A-Z]{0,3}[\']+){5}
Replace With: \1\r\n

The above in Notepad++ (version 6.8.8) will find/match

,'','a','bc','def','ghi'

but it replaces it with

,'ghi'[CR][LF]

I've also tried replacing with \1\2\3\4\5\r\n, and it yields the exact same result. Any ideas would be greatly appreciated.

2
  • What's the output you're expecting?
    – tachomi
    Jan 19, 2016 at 16:02
  • I'm expecting it to replace ,'','a','bc','def','ghi' with ,'','a','bc','def','ghi'[CR][LF]
    – Jpsh
    Jan 19, 2016 at 16:07

1 Answer 1

0

Replace With: $0\r\n ended up working I guess \1 was for versions before 6.

1
  • Nope - \1 is a first capturing group ([\,]+[\']+[A-Z]{0,3}[\']+) which you are matching 5 times, so \1 in replace capture the last match. (([\,]+[\']+[A-Z]{0,3}[\']+)) capture group is what you have been expected to match \1 while \2 is still the last '...' in line. However you have found better RegEx anyway...
    – g2mk
    Jan 21, 2016 at 22:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .