Steve's Handy GREP docs

Find and replace a block of text when you know the start text and the end text, but not the text in the middle

requires: BBedit (or UNIX command line)

Let's say you need to find the piece of text that's the name of a file, and change it into a link to that file.

Example:

<span class="header">FILE: </span><span id="fileName">ArcadeXmas.jpg</span>

We want to find "ArcadeXmas.jpg" and replace it with a link to that file.

grep magic: <span class="header">FILE: </span><span id="fileName">(.+[g|f])

what it means:

OK - now that we've found the text we want, what next?:
Take the following, paste it into the "replace" box in bbedit & turn on "grep"

<span class="header">FILE: </span><span id="fileName"><a href="../pathname/\1">\1</a>

what it means:

grep magic: [\s\S]+

what it means:

Example:

<body>
lots of lines of code that is different in every file you have to work with
<table>

In BBedit, place this: <body>[\s\S]+<table> in the find command. Replace with anything you like. Can also be used in the find command to go through all the files in directories using the multi-find stuff in the find command. The Catch This bit of grep magic is a "greedy" and can match nearly all the stuff in your documents! Search the bbedit docs for "non-greedy quantifiers" to learn how to get around this.

Example:

^\s+[0-9]\.

This searches your document for lines like this:

1. blah blah blah

what it means: