Cmd-F to open the search dialog.

Use this “Find” string:  (?s)(?<=\bAAA\b).*?(?=\bBBB\b)

Make sure “Grep” and “Case sensitive” are checked.
Make the “Replace” string empty.

Click “Replace All”.

\bAAA\b and \bBBB\b match “AAA” and “BBB” only when they appear as complete 
words. If that isn’t what you want, omit the \b markers.

(?<=\bAAA\b) means that the matched string must be immediately preceded by AAA, 
but that the AAA isn’t part of the matched string. Similarly, (?=\bBBB\b) means 
that the matched string must be immediately followed by BBB, but that the BBB 
isn’t part of the matched string.

.*? matches the string between the AAA and BBB. Using .*? instead of .* means 
that if there are multiple BBBs in the file, the match is only up to the first 
one, not the last one. Enclosing it in (?s:.*?) means that . will match line 
breaks as well as ordinary characters, so the matched string can span multiple 
lines.

Example:

Initial file contents:

hello mother
AAA
this
is ?::k
BBB
hello father

After the replacement:

hello mother
AAABBB
hello father

Note that this does exactly what you described: everything between the AAA and 
BBB is deleted, including all the line breaks, so they end up jammed together. 
If what you really meant was that the AAA and BBB should each stand alone on a 
line of its own, and that only the lines between them should be deleted, then 
this Find string will work: (?<=^AAA\n)(?s:.*?)(?=^BBB$)

(?<=^AAA\n) says that the prefix string is a line containing just AAA, and 
includes the line break at the end of the line, so the matched string does not 
include the line break. (?=^BBB$) says that the suffix string is a line 
containing just BBB, not including the line breaks, so the line break before 
the suffix string is part of the matched string.

Regards,

        Neil Faiman

On Sep 18, 2021, at 4:56 AM, Nowaki A <dreamland...@gmail.com> wrote:
> 
> I have a thousands of word file with the contents I want to delete.
> All the contents I want to delete are between exactly the same two specified 
> words. 
> How do I replace or remove the contents?
> 
> For example
> 
> AAA
> ***************
> ***************
> ***************
> ***************
> ***************
> BBB
> 
> * = The contents with all sorts of characters. 
> 
> I want to remove or replace everything between AAA and BBB. 
> How do I do that?
> Please help. 
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "supp...@barebones.com" 
> rather than posting here. Follow @bbedit on Twitter: 
> <https://twitter.com/bbedit <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 bbedit+unsubscr...@googlegroups.com 
> <mailto:bbedit+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/1787296b-0bc5-4c63-bf92-df97240da040n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/bbedit/1787296b-0bc5-4c63-bf92-df97240da040n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" 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 bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/7DA808CD-44DC-4A1F-B503-BE2746224C32%40faiman.org.

Reply via email to