0

I am trying to match every line containing the string "Random Data" only if its between "Index 100" including that string. Is this possible?

Index 000

Index 100

Random Data Random Data

Not Random Data

Random Data Random Data

Not Random Data

Index 100

Random Data Random Data

Not Random Data

Random Data Random Data

Not Random Data

Index 100

Index 200

Can't seem to get it, I was playing around on https://regexr.com/ but no luck.

I took the regex from this post Regex Match all characters between two strings

and attempted to modify it with no luck. I tried this

(?<=Index 100)\R*Random*\R*(?=Index 200)

I am completley new to regex, a little direction would be great.

Community
  • 1
  • 1
arealhobo
  • 447
  • 1
  • 6
  • 17
  • Are you using it in `findstr`? – Wiktor Stribiżew Feb 20 '18 at 20:25
  • 1
    What is this? A webpage? A text file? – zer00ne Feb 20 '18 at 20:27
  • This requires programmatic logic to do, at least if you are trying to find all instances of "Random Data" but not "Not Random Data"; otherwise you'll only match the first or last between two Index 100 values. `findstr` is also appears to have very limited regex abilities and probably can't do this; you'd be much better off using `select-string` if you have access to PowerShell. Finally, you would need `\r?\n` to match line breaks instead of `\R` unless findstr has some special meaning for `\R` – NextInLine Feb 20 '18 at 20:32
  • 1
    The question is very unclear: tagged with `findstr`, tests performed in a JavaScript regex tester, and the pattern is actually PCRE/Java/Boost/Onigmo compatible. Too unclear. – Wiktor Stribiżew Feb 20 '18 at 21:44
  • Yes the plan is to use findstr, this is for a text file. I am new to regex so I wasn't sure if this was possible with regular expressions. Thank you all. – arealhobo Feb 21 '18 at 00:10

0 Answers0