Is there a way to put a section of a line at the start of every subsequent line using regular expressions?

59 Views Asked by At

I have a text file in which there is a line with the category and then all items of that category in lines below it. This is followed by 2 empty lines and then the title of the next category and more items in the category. I want to know how I could use regular expressions (specifically with Notepad++) in order to put the category at the start of each of the item's lines so I can save the file as a CSV or TAB file.

I started by isolating one of the categories as such:

Городищенский поссовет  1541
Арабовщина  535
Болтичи 11
Бриксичи    59
Великое Село    160
Гарановичи  34
Грибовщина  3
Душковцы    5
Зеленая 182
Кисели  97
Колдычево   145
Конюшовщина 16
Микуличи    31
Мостытычи   18
Насейки 5
Новоселки   45
Омневичи    53
Поручин 43
Пруды   24
Станкевичи  42
Ясенец  33


I then got as far as getting to be finding for

(.+)(поссовет)(\t\d{4}\r\n)(^.*$\r\n)

and replacing with

$1$2\t$4

which makes the first line

Арабовщина  535

turn into

Городищенский поссовет  Арабовщина  535

which is what I want to happen to the rest of the lines but I couldn't get any farther.

0

There are 0 best solutions below