c# - RegularExpressionValidator behaves differently than UnitTest RegEx -
i created regex our needs - wrote unittest , after passed wanted upgrade frontend new regex - requiredfieldvalidator somehow doesn't match exact same string unittest does.
here's unittest passes fluently:
[testmethod] public void basictest() { using (shimscontext.create()) { var basicunicoderegex = new regex(@"^(?:(?:\p{isbasiclatin}|\p{islatin-1supplement}|\p{islatinextended-a}|\p{islatinextended-b}|\p{isipaextensions}|[\u0302\u030c]|\p{islatinextendedadditional}){2,}[*]?)$"); var ismatchstring = "floriân-d̂îétrich wäßterh@gen 1823*"; var isnotmatchstring = "べξぺき"; assert.istrue(basicunicoderegex.ismatch(ismatchstring)); assert.isfalse(basicunicoderegex.ismatch(isnotmatchstring)); } }
and that's asp controls don't exact same string nor basic a-z one:
<asp:textbox runat="server" id="edtnachname"></asp:textbox> <asp:regularexpressionvalidator id="rev_nachname" runat="server" controltovalidate="edtnachname" errormessage="nope" validationexpression="^(?:(?:\p{isbasiclatin}|\p{islatin-1supplement}|\p{islatinextended-a}|\p{islatinextended-b}|\p{isipaextensions}|[\u0302\u030c]|\p{islatinextendedadditional}){2,}[*]?)$"> </asp:regularexpressionvalidator>
what's going on here? :o
seems regularexpressionvalidator doesn't support namedblocks (ref: https://msdn.microsoft.com/en-us/library/20bw873z(v=vs.110).aspx#supportednamedblocks)
changing unicode ranges - in case:
^(?:[\u0000-\u02af]|[\u0302\u030c]|[\u1e00-\u1eff]){2,}$
- works fine
Comments
Post a Comment