Surrounding a portion of your match expression with parentheses “captures” the
part of the original text matched by that part of the match expression.
Captured bits of text may then be used in the replacement expression, denoted
by \1, \2, etc, for each successive set of parens, counting from the left.
So if your whole match expression is as per your question, but enclosed by
parens:
(^\n?.{50})
then \1 contains a possible newline and 50 characters following it. If you put
the parens only around .{50}, it would only capture the fifty characters.
So if you put parens as I showed above, then you could use:
find: (^\n?.{50})
replace: \1\n
The replacement here is the captured text plus a newline.
(One wrinkle to watch for is the the dot ‘.’ in that expression matches any
character EXCEPT newlines.
The BBEdit manual, available under the Help menu as a quick PDF download, has a
great chapter on this: Searching with Grep.
— Bruce
_bruce__van_allen__santa_cruz_ca_
> On Jun 5, 2023, at 4:24 AM, Otto Munters <[email protected]> wrote:
>
> In Find and Replace I can do this search:
>
> ^\n?.{50}
>
> But I can't figure out how to replace the same words followed by a line break.
>
--
This is the BBEdit Talk public discussion group. If you have a feature request
or need technical support, please email "[email protected]" rather than
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/bbedit/C1CB9328-D0B5-4716-A582-61FE171FD5C2%40cruzio.com.