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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Extract VBScript/VB code blocks
Expression
(?<Code>[\s\S]*?)(?<NonCode>'.*?\r?\n|(?<quot>"|')(?:(?:(?!\<quot>).|\<quot>{2})*)(?:\<quot>))
Description
This expression matches all VBScript or VB code. Line comments (with ') and strings are inlcuded in named groups. Strings with double quotes (i.e. "this is my ""string"".") is supported. Expression is only tested with RegEx for .net 2.0.
Matches
Response.Write "my ""quoted"" string" ' some comment
Non-Matches
..
Author Rating: The rating for this expression. Torbjörn Hansson
Source
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: Extract VBScript/VB code blocks
Name: Swakke
Date: 4/15/2011 9:11:32 AM
Comment:
Hello Hansson, your expression is great but I have a problem with it. When in a text le last comment (') - and also the last line - doesn't end with a CR/LF there is no match !!! I hope i'm not wrong and how can we fix this ? Thank you in advance for your reply. Swakke


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