M
Masa Ito
I am trying to capture the contents of a function with Regex. I am using
Expresso to test (nice - thanks for the great tool UltraPico!). I can
handle my own with single line regex's (I think).. I want to have a
named capture of the entire 'contents' of specific functions.
EG: Sample code
<Description("{0} is a required field.")> _
Protected Overridable Function AccountIDRequired(ByVal target As
Object, ByVal e As RuleArgs) As Boolean
Return mAccountID.ToString.Length > 0
End Function
I know the function name, and can easily match the first line:
Protected\sOverridable\sFunction\sAccountIDRequired.*
But the .* doesn't capture the newlines (/n). I want to capture
everything up to the End Function, so figured I could do something like:
(Protected\sOverridable\sFunction\sAccountIDRequired.*End\sFunction)
If I know that it is always 3 lines (like the example) I could do:
Protected\sOverridable\sFunction\sAccountIDRequired.*\n.*\n.*
this matches my test perfectly, but I need it to match as many lines as
necessary until the End Function.
Can anyone help?
TIA!
Expresso to test (nice - thanks for the great tool UltraPico!). I can
handle my own with single line regex's (I think).. I want to have a
named capture of the entire 'contents' of specific functions.
EG: Sample code
<Description("{0} is a required field.")> _
Protected Overridable Function AccountIDRequired(ByVal target As
Object, ByVal e As RuleArgs) As Boolean
Return mAccountID.ToString.Length > 0
End Function
I know the function name, and can easily match the first line:
Protected\sOverridable\sFunction\sAccountIDRequired.*
But the .* doesn't capture the newlines (/n). I want to capture
everything up to the End Function, so figured I could do something like:
(Protected\sOverridable\sFunction\sAccountIDRequired.*End\sFunction)
If I know that it is always 3 lines (like the example) I could do:
Protected\sOverridable\sFunction\sAccountIDRequired.*\n.*\n.*
this matches my test perfectly, but I need it to match as many lines as
necessary until the End Function.
Can anyone help?
TIA!