Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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).

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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