Padmanabhan Ramji
Padmanabhan Ramji

Reputation: 11

Notepad++ - Regex - Insert below matching line

Given:

$apple hello

After running code, I expect:

$apple hello
found

But its not working, I am getting :

$apple 
found hello

Upvotes: 0

Views: 66

Answers (1)

Toto
Toto

Reputation: 91385

  • Ctrl+H
  • Find what: \$apple(?!.*\$apple).*?\R
  • Replace with: $0Found
  • CHECK Match case
  • CHECK Wrap around
  • CHECK Regular expression
  • CHECK . matches newline
  • Replace all

Explanation:

\$apple         # literally $apple
(?!.*\$apple)   # make we haven't $apple after
.*?             # 0 or more any character, not greedy
\R              # any kind of linebreak

Replacement:

$0          # the whole match, including linebreak
Found       # literally

Screen capture (before):

enter image description here

Screen capture (after):

enter image description here

Upvotes: 1

Related Questions