Notepad ++ - Regex - вставить под соответствующей строкой - PullRequest
0 голосов
/ 07 февраля 2020
  • Найти что: (\$apple)(?!.\$apple)
  • Заменить: \1\nFound

Дано:

$apple hello

После запуска кода я ожидаю:

$apple hello
found

Но это не работает, я получаю:

$apple 
found hello

1 Ответ

1 голос
/ 07 февраля 2020
  • Ctrl + H
  • Найти что: \$apple(?!.*\$apple).*?\R
  • Заменить на: $0Found
  • ПРОВЕРКА Матч
  • ПРОВЕРКА Обтекание
  • ПРОВЕРКА Регулярное выражение
  • CHECK . matches newline
  • Заменить все

Пояснение:

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

Замена:

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

Снимок экрана (до):

enter image description here

Снимок экрана (после):

enter image description here

...