What happens when you try your pattern against some real text? How is that different to what you expect?
Just looking at the pattern I would make a couple of comments:
1) the [.\n]* sub-pattern is greedy which means that it will match ALL of the following:
Public Sub New()
HelloString = "Hi"
End Sub
Private Function ErrorCode()
HelloString = "Error"
End Function
2) You just look for 'sub' at the start but allow 'sub' or 'function' at the end
3) While it is not wrong, you can make the last part of the pattern
(END\s+(SUB|FUNCTION))
4) This will find text in comments which is probably not a good place to look
Actually, you can make this a bit tighter with something like
^\s*(public|private)\s+(sub|function)\s+NEW ..other stuff here.. ^\s*END\s+\2$
if you read the posting guidelines at http://regexadvice.com/forums/thread/37499.aspx you will see that we really require a number of things that you have not given us before we can really help. In particular, some real text, the regex (I'm assuming .NET) and a good description of what you are looking for and what you asre trying to do.
Susan