On 10/11/16 at 9:47 AM,
pierre-oli...@hotmail.com
(Pierre-Olivier Bonin) wrote:
[...example elided...]
>
>Now, what I would like to do is to select everything ranging
>from the first word ("Title") and the last word ("Database") of
>the irrelevant section, and delete it.
Though Steve's suggested patterns will certainly work, I suggest
you instead just use brute force :-) as such a pattern is
simpler to write and you needn't worry about recursion.
If you want to match and delete all the text starting with
"Title" through the end of the line that starts with "Database",
then try:
Find: ^Title(?s).+?\nDatabase.+?$
Replace: # leave this field empty
For reference:
This pattern starts by matching the string "Title" at the start
of a line ^ and continues with the modifier (?s) which allows
the following ".+", meaning 'one or more instances "+" of any
character "."', to match across linebreaks, followed by "?" to
make that match _non-greedy_ and then wrapping up by matching a
literal line break \n followed by the string "Database" and
another non-greedy run of characters through the end of that
line $.
If instead you want to delete all the text from "Title" down to
but _not_ including the line that starts with "Database", then:
Find: ^Title(?s).+?\nDatabase
Replace: \nDatabase
This pattern works very much like the preceding, except it ends
at a plain string match and then instead of just deleting all
the matched text, does that and then inserts a hard line break
followed by the string "Database".
On a more general note :-), please see Chapter 8 of the included
PDF manual (which you can open at any time via Help -> User
Manual) for complete details on using grep patterns with
TextWrangler's search & replace commands.
Regards,
Patrick Woolsey
==
Bare Bones Software, Inc. <
http://www.barebones.com/>