I need to extend this regex to remove space characterless. We use ASP.NET validation using asp:RegularExpressionValidator so I can’t use replace method in between.
Here is my Regex:
\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
Hre the code
<asp:TextBox ID="tbBIEmailAddress" runat="server" CssClass="inpText" MaxLength="50" />
<asp:RequiredFieldValidator id="reqValBIEmail" runat="server" ControlToValidate="tbBIEmailAddress" Display="Dynamic" ValidationGroup="Checkout">*</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator id="regValBIEmail" runat="server" ControlToValidate="tbBIEmailAddress" ValidationGroup="Checkout" ValidationExpression="\^w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">*</asp:RegularExpressionValidator>
I know that .Net has the concept of variable number of capture buffers.
So for instance,
(asw[^p]+)*should create a capture buffer 1 object thatstores data as an array.
However, its not clear how it would react in this case:
(?:([-.]\w+)|\s+)*Clearly
\sis not in the scope of a capture buffer, and should not be included inthe group 1 capture buffer object array. In effect stripping whitespace in the
process of capture. But I didn’t test this.
I could be reading your question wrong though and for all I know, you are using capt groups for just grouping.
added
Your sample might have a typo.
This:
"\^w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"should probably be this:
"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"Its possible that explains your space problem but probably not.