开发者

Regular Expressions Exclude From a class

I'm building a dynamic code generator and using regular expressions. Given this block of text

##Properties
       开发者_运维百科                     public #PropertyType# #NewProperty#
                            {
                                get; set;
                            }
##
##Events
                            public event #EventName#-#EventExt#;
##
                            }
                            #endregion

I want to be able to extract to blocks of text, namely:

##Properties
                            public #PropertyType# #NewProperty#
                            {
                                get; set;
                            }
##

and

##Properties
                            public #PropertyType# #NewProperty#
                            {
                                get; set;
                            }
##

I've been trying to use this ##[\S\s]+## as my expression but it's taking both and joining them into one. So I was wondering if there was a way to exclude the "##" characters from the [\S\s] class so that it doesn't get recognized. Is there such a way to do this?


Try using lazy on your regular expression:

##[\S\s]+?##

This will match as few characters as possible.


Try

##(?:[^#]|#(?!#))+##
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜