RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^(?<Code>([^"']|"[^"]*")*)'(?<Comment>.*)$
Description
This expression separates a Visual Basic (VB) source code line into the code part and the comment part (if any, following an apostrophe character not enclosed in quote marks).
Matches
a = b ' Comment | a = "xy'z" ' Comment
Non-Matches
a = b | rem not supported
Author Rating: Not yet rated. Robert Altman
Source Based on an expression posted on MS newsgroup microsoft.public.dotnet.framework by Mark Hurd, B.Sc.(Ma.) (Hons.)
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: One case that does not work
Name: Chris Strolia-Davis
Date: 11/26/2004 3:14:47 PM
Comment:
Note: Multiline must be on for expression to work. In the following case, the comment and code are interpreted as being on the same line: Sub MySub(optional x as string = "There is no ' comment in this line") ' This is a comment line


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials