Ersetzen von regulären Ausdrücken im Textpad, wenn der Suchbegriff mehrere Zeilen umfasst

6335
Warren Blumenow

Ist es möglich, einen regulären Ausdruck zu suchen und in Textpad zu ersetzen, wenn der Suchbegriff mehrere Zeilen umfasst.

zB Dokument enthält:

Hello ab_c D_EF 12_3 World 

Ich möchte alles zwischen "Hallo" und "Welt" durch ein Leerzeichen ersetzen.

Ich habe versucht, nach dem regulären Ausdruck zu suchen:

Hello.*World 

Dies stimmt jedoch nicht überein (ich gehe davon aus, dass der Text mehrere Zeilen umfasst).

1

1 Antwort auf die Frage

0
speakr

Since Textpad seems to have only very limited regex support, I only got it done with three replaces:

  1. Replace each newline (\n or \r\n) in your text with a unique pattern, e.g. ##NEWLINE##

  2. Use the regex (Hello).*(World) and replace the match with \1 \2
    (you can also just use Hello.*World and replace with Hello World)

  3. Finally, revert step 1 by replacing all ##NEWLINE## with the actual newline


I suggest taking a look on Notepad++ which has better regex support, a lot of other features (especially for source code editing), and is open source / free software.