0

I have a bunch of files that are saved in a .pg format. I can open and edit them using notepad++.

I want to prepend in every file the same header. Is there a regular expression that could select all text in a file so that I could search and replace to add my header?

So that

Some text in file 1

Some text in file 2

... becomes

becomes

Header
Some text in file 1

Header
Some text in file 2

...

  • looks like something you could do using cat/type - see http://stackoverflow.com/questions/60244/is-there-replacement-for-cat-on-windows – Leo Sep 12 '14 at 14:49
  • `\A`(beginning of string) you can prepend your `Header` text. Search-replace on `\A` and add `Header\n`. This might not work in all editors tho, so I'm not sure if it will work on a file's contents. –  Sep 12 '14 at 14:49
  • Both answers below add header before each lines yeah – Jean-Sébastien Sep 12 '14 at 15:11
  • Possible duplicate of [How to replace only first instance of text in notepad++ in multiple files?](http://stackoverflow.com/questions/15848690/how-to-replace-only-first-instance-of-text-in-notepad-in-multiple-files) – AdrianHHH Sep 16 '16 at 08:47

3 Answers3

0

I think this should work,

Regex:

(?s)^

Replacement string:

Header\n
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274
0

Find:

(.*)^

Replace:

THIS IS THE FOOTER

Be sure you check the . matches newline box in the Search Mode box (as well as selecting Regular expression).

-1

You can use this search/replace:

search: ^
replace: Header\n
Casimir et Hippolyte
  • 88,009
  • 5
  • 94
  • 125