Regular Expression to Grab an Object Reference Name from a C# Code File.

/ Published in: Regular Expression
Save to your folder(s)

This expression grabs the token preceding the = sign which precedes the keyword new. The expression within the parenthesis is a positive lookahead which matches an equal sign followed by zero or more spaces, then zero or more characters (for example an explicit cast) followed again by zero or more spaces, finally the keyword new, and at least one space.

Copy this code and paste it in your HTML
  1. \S*\s*(?=\=\s*\S*\s*new\s)

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.