Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Find Using Regular Expression Look Behind

Using Visual Studio 2013, how would I find all occurrences of Sheet but not if it is MVC.Sheet?

I cannot figure out look behind.

This works to find ones that are not followed by .Index: Sheet(?!.Index)

like image 495
Kevin Swarts Avatar asked Jun 20 '14 17:06

Kevin Swarts


People also ask

What is regex look behind?

Lookbehind has the same effect, but works backwards. It tells the regex engine to temporarily step backwards in the string, to check if the text inside the lookbehind can be matched there.

How do you use negative look ahead?

Negative lookahead That's a number \d+ , NOT followed by € . For that, a negative lookahead can be applied. The syntax is: X(?! Y) , it means "search X , but only if not followed by Y ".

What is a negative Lookbehind?

A negative lookbehind assertion asserts true if the pattern inside the lookbehind is not matched.

Does JavaScript regex support Lookbehind?

JavaScript doesn't support any lookbehind, but it can support lookaheads.


1 Answers

Working in VS2013 (see screenshot):

(?<!MVC\.)Sheet
  • The (?<!MVC\.) lookbehind asserts that what precedesis not MVC.
  • Sheet matches Sheet

Visual Studio

Reference

  • Lookahead and Lookbehind Zero-Length Assertions
  • Mastering Lookahead and Lookbehind
like image 167
zx81 Avatar answered Sep 23 '22 17:09

zx81