Reputation: 7979
My project is developed by many people. Many of the developers have commented few of their codes
I have a lot of codes like
//ServiceResult serviceResult = null;
//JavaScriptSerializer serializer = null;
//ErrorContract errorResponse = null;
They use // ,they don't use /**/ How can I find all such commented line in visual studio 2012 using regular expression
In that find it should not find any xml comments with ///
Upvotes: 4
Views: 118
Reputation: 21437
Simply try as
(?<!/)//.*(?!/)
(?<!/)
Negative Lookbehind - To check the //
doesn't contains /
as a preceding character //.*
Matches any character including //
except newline(?!/)
Negative Lookahead - To check the //
doesn't contains /
as a next characterUpvotes: 3
Reputation: 3176
This should cover most spacing cases and work in all VS versions. I believe look-behinds are only supported in VS2013.
^(?:\s|\t)*?//(?!/\s*<).+$
Upvotes: 1
Reputation: 11233
Try this regex:
^\s*(?<!/)(//(?!/).+)$
First group should give you the commented line.
Upvotes: 1
Reputation: 8163
Try this expression (?<!\/)\/\/[^\/].*
and for .NET
as someone mentioned: (?<!/)//[^/].*
Upvotes: 1
Reputation: 1101
use this patten
(?<!/)//(?!/)
(?<!/)
means it can not be /
before //
(?!/)
means it can not be /
after //
Upvotes: 2