Leo
Leo

Reputation: 27

Notepad++ add specific string each line

I have to add specific string each line in Notepad++. How can I do? Thanks!

Before:

I am a boy A.
I am a girl A.

After:

I am a boy A boy.
I am a girl A girl.

Upvotes: 3

Views: 429

Answers (3)

Toto
Toto

Reputation: 91385

After you've checked the regular expression choice:

Find: (\S+)\s(\S+)\.$
replace: $1 $2 $1.

Upvotes: 0

Tschallacka
Tschallacka

Reputation: 28722

CTRL + H

at search method select

Expandend (\n, \r, \t, \0, \x...)

and with the search fields you select

At search for you enter : \n 
At Replace by you enter : My specific string \n

Or use macro's

  • menu > Macro > start recording
  • Hit [END]
  • Press left arrow <-
  • press down CTRL + SHIFT and hit the <- left arrow once so the last word is selected
  • press right key ->
  • hit SPACE
  • press CTRL + V
  • menu > Macro > stop recording
  • menu > Macro > Save Macro
  • Name: Name of the macro
  • Key combination of which keys will trigger the macro
  • Press OK.

Upvotes: 0

Kobi
Kobi

Reputation: 138017

Open the Replace window and check Regular expression:

Find what: \b(\w+)\.$
Replace with: \1 \1.

\b(\w+)\.$ is a simple regex that matches the last word before the period. The word is captured into the first group (\1 or $1 both work in Notepad++), so it can be used twice while replacing.

Upvotes: 1

Related Questions