Say I have a situation where I need to search for the word 'Foo' in a document but I only want it to match if the word 'Bar' appears anywhere else in that document (i.e. 'Bar' can be on the same line, a different line, before or after 'Foo'). Can I use a Regular Expression to do this?
Following the link in this SE post, I've tried:
Foo(?=.*\nBar)|Foo(?=.*Bar)|Foo(?<!.*Bar)|Foo(?<!.*\nBar)
which works great if Foo is missing, but it still selects Foo even if Bar is missing. I've also checked this SE post, but all the answers speak of Java/Perl, and do not work using .NET.
Is it possible to accomplish this using Regular Expressions in .NET, or do I need to resort to using a C# && operator in the code itself?