I have tried to find all Validators in our project in Visual Studio 2010. Those are like that:
<asp:RequiredFieldValidator
ID="validator"
runat="server"
ErrorMessage="*"
ControlToValidate="control"
Display="Static"
ValidationGroup="main">*</asp:RequiredFieldValidator>
or
<asp:RequiredFieldValidator
ID="validator"
runat="server"
ErrorMessage="*"
ControlToValidate="control"
Display="Static"
ValidationGroup="main"
Text="*"/>
I have tried with below validators with no results:
(\<asp\:[a-zA-Z]*Validator)~((.|\n)*ValidationGroup)(.|\n)*\/\>
(\<asp\:[a-zA-Z]*Validator)~(ValidationGroup)(.|\n)*(\<\/asp\:[a-zA-Z]*Validator\>)$
Do you see any bugs in them?
EDIT:
I have tried with below successfully (but only on site http://derekslager.com/blog/posts/2007/09/a-better-dotnet-regular-expression-tester.ashx):
\<asp\:[a-zA-Z]*Validator(?![^/]*ValidationGroup)[^/]*\<\/asp\:[a-zA-Z]*Validator\>
But when I replaced ?! with ~ it still doesn’t work in Visual Studio.
But probably mellamokb posted correct answer!
I built this VS regex which seems to work for the first case:
I took your basic idea and searched for each attribute individually with the expression
(:b|\n)+[a-zA-Z]+\"[^"]*". Then I search for multiples to grab all the attributes, and finally added a~(ValidationGroup)to prevent the matching from completing if any of the attributes are named ValidationGroup.