On Tue, Aug 21, 2007 at 11:27:46AM -0400, Chris Pepper wrote:
>       I believe BBEdit can do this, but I have been unable to parse 
> the answer out of "Conditional Subpatterns" in the Help's "Searching 
> with Grep", and suspect it's simple for folks here. I need to unwrap 
> configuration stanzas for a Big-IP load balancer. I want to perform 
> either one of 2 transformations:
> 
> a)    If the last character on a line *is not* '}': remove the next return.
> b)    If the last character on a line *is* '}': leave the return, 
> and add 'b ' before the next line.
> 
>       I think Search For should be '(.)\r', but I haven't been able 
> to gin up a suitable Replace With.

Conditional Subpatterns are for doing conditional matching, but what you
actually want is conditional *replacement*, which is not something you can
do with a simple grep.

You could do what you want with two greps:

Find
(?<!\})\r(?!\z)

Replace

(replace with nothing)


Find
\}\r(?!b |\z)

Replace
}\rb 
(trailing space)


The (?!\z) keeps the last line in the file from being affected.

I'm assuming there won't be any blank lines in the file.

Neither of those greps should affect lines that have already been fixed, so
you can run them repeatedly to fix any new lines without breaking the old
lines.

Ronald

-- 
------------------------------------------------------------------
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]>

Reply via email to