I can't get my regex to match the header of a c# code file. I basically want need to return the header if it exists.
Example:
#define debug
//****************************************************************************************************
// <copyright file="" company="">
// Copyright (c) . All rights reserved.
// </copyright>
// <project>Engine</project>
//****************************************************************************************************
code here
//some other comment here
more code here
//another comment here
My regex looks like this:
(?:/\\*(?:[^*]|(?:\\*\+[^*/]))*\\*\+/)|(?://.*)
but it only matches this line: //****************************开发者_StackOverflow社区******************************
and not the rest of the comment.
Comments can also end like this "*/"
.
whats wrong with my regex? why doesn't it catch the whole block?
Try this one - and you can pull out the entire comment (with the "//" or the group within to get just the text. This will return a match for each line. Please use the "Multiline" option to run this:
^/[/|*](.+)$
Need multiline
(^\/\/.*?$|\/\*.*?\*\/)
I guess you'd like to extract the pseudo-xml code so the following expression should work. Note that you'll still have to remove the leading "//" in each line.
//\*+\n((?://.*\n)+)//\*+
Using the regex pattern: (/*([^]|[\r\n]|(*+([^/]|[\r\n])))*+/)|(//.)
see more https://code.msdn.microsoft.com/How-to-find-code-comments-9d1f7a29/
精彩评论