C# Can';不要在RegularExpressionValidator中生成非常简单的正则表达式

C# Can';不要在RegularExpressionValidator中生成非常简单的正则表达式,c#,asp.net,regex,C#,Asp.net,Regex,我有一个非常简单的正则表达式,我无法在ASP.NET RegularExpressionValidator上工作。 我的代码如下: <asp:RegularExpressionValidator ID="revtxtNumeroLiderAnterior" ControlToValidate="txtNumeroLiderAnterior" ErrorMessage="*" ValidationGroup="NumeroLiderAnter

我有一个非常简单的正则表达式,我无法在ASP.NET RegularExpressionValidator上工作。 我的代码如下:

<asp:RegularExpressionValidator ID="revtxtNumeroLiderAnterior" ControlToValidate="txtNumeroLiderAnterior" ErrorMessage="*"
                         ValidationGroup="NumeroLiderAnterior" ValidationExpression="^(\d+)(\s)(-)(\s)" runat="server"
                        CssClass="TextosNaranja" ></asp:RegularExpressionValidator>
我不知道为什么,我在一些网站上验证了它,并且表达式匹配


请帮帮我,它与整个字符串不匹配。。它所匹配的只是数字、破折号和一些空格。您需要检查单独的组匹配,如果这是您想要的(不记得如何使用RegexValidator)

要匹配整个内容:

^(\d+)(\s)(-)(\s)([\w\s]+)
                 ^^^^^^^^^^^^^ capture the words
^(\d+)(\s)(-)(\s)([\w\s]+)
                 ^^^^^^^^^^^^^ capture the words