Not sure if this is required, but I have developed solutions that allow for a matching group to appear multiple times within the input file. Each solution preserves all instances of the matching group.
For the code below, I assume the data is in "input.txt", and the output is to go in "output.txt"
Here is simple batch code that performs reasonably well for pure batch:
@echo off
setlocal disableDelayedExpansion
set "print="
(for /f "delims=" %%A in (input.txt) do (
if defined print for /f "delims=1" %%B in ("%%A") do if "%%B" equ "B" set "print="
if not defined print for /f %%B in ("%%A") do if "%%B" equ "B10119628000D5" set print=1
if defined print echo %%A
)) >output.txt
The above may become quite slow if the file is very large.
I have written a hybrid JScript/batch utility called REPL.BAT that can be used to make an even simpler solution that is quite efficient. REPL.BAT is pure script that will run natively on any modern Windows machine from XP onward. Full documentation is embedded within the script.
I use REPL.BAT to encode newlines that do not precede "B1" as "@", thus turning a group of lines into one line. Then FINDSTR is used to preserve only the desired lines (matching "groups"), and a final REPL.BAT decodes the "@" back into newlines. If the data may contain "@", then substitue some other character that does not exist within the data.
type input.txt|repl \n(?!B1) @ m|findstr /bc:"B10119628000D5 "|repl @ \n x >output.txt
If you can't find a character that does not exist in the data, then "@" can be protected by an additional round of encode and decode:
type input.txt|repl @ @a|repl \n(?!B1) @n m|findstr /bc:"B10119628000D5 "|repl @n \n x|repl @a @ >output.txt
If the space is not required after the search string filter, as per comment, then the solutions change as follows:
option1:
@echo off
setlocal enableDelayedExpansion
set "print="
(for /f "delims=" %%A in (input.txt) do (
set "ln=%%A"
if defined print if "!ln:~0,2!" equ "B1" set "print="
if not defined print if "!ln:~0,14!" equ "B10119628000D5" set print=1
if defined print echo %%A
)) >output.txt
option 2:
type input.txt|repl \n(?!B1) @ m|findstr /b B10119628000D5|repl @ \n x >output.txt
option 3:
type input.txt|repl @ @a|repl \n(?!B1) @n m|findstr /b B10119628000D5|repl @n \n x|repl @a @ >output.txt