四个名字的正则表达式

Any*_*are 0 regex asp.net validation

我想对名称进行验证,强制用户在四个部分(四个名称)中输入他的名字.如何在客户端使用asp.net验证?

<td style="text-align: right;" class="style1">
    <asp:TextBox ID="txt_addName" runat="server" Width="220px" ValidationGroup="add"></asp:TextBox>
    <cc1:TextBoxWatermarkExtender ID="txt_addName_TextBoxWatermarkExtender" 
        runat="server" Enabled="True" TargetControlID="txt_addName"
        WatermarkText="???? ??? ??????? ??????" WatermarkCssClass="watermark">
    </cc1:TextBoxWatermarkExtender>
    &nbsp;
    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
         ControlToValidate="txt_addName" Display="Dynamic" ErrorMessage="!"     
         ValidationGroup="add"></asp:RequiredFieldValidator>
    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="*"
        ValidationExpression="^(?:\p{L}+\s+){3}\p{L}+$" ControlToValidate="txt_addName"
        Display="Dynamic" ValidationGroup="add">??? ?? ???? ??? ??????? ?????? 
    </asp:RegularExpressionValidator>
</td>
<td style="text-align: center; width: 550px;">
     <asp:Button ID="btn_addNewLecterer" runat="server" Font-Bold="True" Font-Names="Garamond"
          Font-Size="Medium" Text="??? ????? ????" OnClick="btn_addNewLecterer_Click" ValidationGroup="add" />
</td>
Run Code Online (Sandbox Code Playgroud)

Fre*_*örk 5

这样的事情应该有效:

^(?:\p{L}+\s+){3,}\p{L}+\s*$
Run Code Online (Sandbox Code Playgroud)

说明:

^      // start at the beginning of the string
(?:    // start a non-capturing group
\p{L}  // match any unicode letter...
+      // ...at least one of them...
\s+    // ...followed by at least one white-space character
)      // end the non-capturing group
{3,}   // repeat the group at least three times
\p{L}+ // finish with at least one unicode character...
\s*    // ...that can optionally be followed by white-space...
 $     // ...and then the string should end
Run Code Online (Sandbox Code Playgroud)

如果你想限制的表达,需要准确四个部分(我解释了一个问题,需要至少为四个),将其更改为:

^(?:\p{L}+\s+){3}\p{L}+$
Run Code Online (Sandbox Code Playgroud)