Replace repeat word w/another word in a new line

A place to try and solve your RegEx problems.
Post Reply
longsack
Posts: 1
Joined: Thu Oct 27, 2022 10:03 pm

Replace repeat word w/another word in a new line

Post by longsack »

I need to replace a repeat word with a word found earlier in the text on each line

EXAMPLE:

('test1', '', '', '', '', '', '', '', '', '', '', '', '', 1, 'test', 'test', 'test', 'test', 'test', '', 1, 0, '');
('test2', '', '', '', '', '', '', '', '', '', '', '', '', 1, 'test', 'test', 'test', 'test', 'test', '', 1, 0, '');
('test3', '', '', '', '', '', '', '', '', '', '', '', '', 1, 'test', 'test', 'test', 'test', 'test', '', 1, 0, '');

EXAMPLE WOULD THEN BECOME THIS:
('test1', '', '', '', '', '', '', '', '', '', '', '', '', 1, 'test1', 'test1', 'test1', 'test1', 'test1', '', 1, 0, '');
('test2', '', '', '', '', '', '', '', '', '', '', '', '', 1, 'test2', 'test2', 'test2', 'test2', 'test2', '', 1, 0, '');
('test3', '', '', '', '', '', '', '', '', '', '', '', '', 1, 'test3', 'test3', 'test3', 'test3', 'test3', '', 1, 0, '');

What would be the regex to make this happen?

Thanks
Post Reply