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

Please support RegExLib Sponsors

Sponsors

Expressions by User

   Displaying page 1 of 1 pages; Items 1 to 1
Title Test Details Pattern Title
Expression
(?<commentblock>((?m:^[\t ]*\/{2}[^\n\r\v\f]+[\n\r\v\f]*){2,})|(\/\*[\w\W]*?\*\/))
Description
This expression will match comment blocks in javascript, c, c++, etc I wrote this as a named group called &quot;commentblock&quot;, as I like to use it with other expressions. It avoids single line comments or inline commented code (which are not considered comment &quot;blocks&quot;) unless the comments are in a /* text */ comment style could not create a multiline example in the matching examples, here is what I tried to enter // Some text //(must be two or more lines long and each line may only be preceded by whitespace)
Matches
/* Some text (may be any number of lines) */
Non-Matches
// Some text (only a single line) | Some code // comment here (even if next line has comment) | /* S
Author Rating: Not yet rated. Chris Strolia-Davis
   Displaying page 1 of 1 pages; Items 1 to 1

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