0

How retrieve all the text between "" among many lines with findstr? For example i have:
Line1
Line2
Line3
"Line 4
Line 5
Line 6
"
Line 7
Line 8

and i need to return
Line 4
Line 5
Line 6

Adrian
  • 3
  • 1
  • 4
  • 1
    Related: [How can I use findstr with newline regular expression](http://stackoverflow.com/questions/5631752/how-can-i-use-findstr-with-newline-regular-expression). – MikeM Mar 27 '13 at 21:19

1 Answers1

0

Working with your sample data... This is as good as I can get without too much effort in rigidity.

'file'txt' contains your data...

@echo off
setlocal enabledelayedexpansion

set quote=

for /f "tokens=*" %%a in (file.txt) do (
  set str=%%a
  set str=!str:"=:!

  if not "!str!"=="!str::=!" (
    if defined quote (
      set quote=
      for %%b in (^"%%a) do set str=%%~b
      if not "!str!"=="" if not "!str: =!"=="" echo !str!
    ) else (
      set quote=1
      for %%b in (%%a^") do set str=%%~b
    )
  )

  if defined quote (
    if not "!str!"=="" if not "!str: =!"=="" echo !str!
  )
)
Paul Tomasi
  • 101
  • 2
  • Your example above works perfectly however i can not make it work to find all the rows between quotes that contain a certain string. So lets say in example above, i need to return Line 4 Line 5 Line 6 (all the lines between quotes with line breaks as above) only if the text between quotes contains Line 5 – Adrian Apr 08 '13 at 20:49