1

Is it possible to do a regular expression search and replace in Textpad where the search term spans multiple lines.

e.g. document contains:

Hello
ab_c
D_EF
12_3
World

I would like to replace everything between "Hello" and "World" with a space.

I have tried searching for the regular expression:

Hello.*World

but this does not match (I assume due to the text spanning across multiple lines).

0

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.