Bowe
Bowe

Reputation: 191

Regular expression to modify the line following a line that begins with a key phrase?

I have a huge file that has some lines that need to have a line of dashes underneath them followed by an empty line.

All of these lines start with the same particular word pattern ("Dollars required for") but every other word on the line is different from one line to the next.

For example, the document looks like this at the moment:

Dollars required for: "International Exchange"
Some other text on the next line
...
Dollars required for: "Trade Operations"
(blank line)
Some other text on the next line

But it needs to look like this:

Dollars required for: "International Exchange"
---------------------------------------------- (inserted line of dashes)
                                               (inserted blank line)
Some other text on the next line
...
Dollars required for: "Trade Operations"
---------------------------------------------- (inserted line of dashes)
                                               (inserted blank line)
(blank line)
Some other text on the next line

Is there a Regular Expression I could use in the Find/Replace feature of my text editor (Jedit) to perform this modification?

Upvotes: 1

Views: 154

Answers (2)

Zsolt Botykai
Zsolt Botykai

Reputation: 51613

Search for:

 ^(Dollars required for: .*)$

Replace with:

 $1\n----------------------------------------------\n\n

Jedit can do it IRC.

Upvotes: 1

Amber
Amber

Reputation: 526763

Find:

Dollars required for: (.*)$

Replace with:

Dollars required for: $1\n----------------------------------------------\n

(This is assuming the find/replace supports escapes for newlines, et cetera.)

Upvotes: 1

Related Questions