Will this still work if the "footer" div has another div nested
within it?
-- Jack
On Jul 8, 2007, at 2:35 PM, Patrick James wrote:
On Jul 8, 2007 Dean Matthews wrote:
How do you set a search and replace grep to replace everything
between two markers.
For example:
Find
<div id="footer"> *oldStuff* </div>
Replace
<div id="footer"> *newStuff* </div>
Hi
I'm diving in fast!
Find:
(<div id="footer">)(.|\r)+?(</div>)
Replace:
\1*newStuff*\3
Don't forget to click "Start at top" if you want to do whole file.
Attempted explanation:
I've put brackets around <div id="footer"> and </div> so that in
the replace
expression I can put them straight back in by matching them with \1
and \3
respectively.
The bit in the middle of Find expression is: (.|\r)+?
Here the . finds all characters except return character. But of
course you
might have return character in *oldstuff* so I've put \r in as well
to get
any of those as well. The vertical bar means "or" then I put
brackets around
.|\r to identify this as being the whole sub-expression if you
like. The
sub-expression says "any characters that aren't return characters
and any
return characters" in other words "any character".
Now after the (.|\r) I put a +. This says one or more of (.|\r).
However it
will be "greedy", the + will just try to grab every character in
the file in
this case, so to stop it being such a greedy thing I put a ? after
it and
that says, stop once you come across what comes next in the
expression, which
of course is (</div>).
I'm new to BBEdit and as a question to those who've used it longer I'm
wondering if BBEdit has a wildcard for "any character at all" to
replace
(.|\r) ?
--
Patrick
<http://www.patrickjames.me.uk>
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>
--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to: <[EMAIL PROTECTED]>