Get the allowed characters from Regex Pattern
hi,
i have created c# windows form has few input fields. validating input fields based on dynamic regular expression (it can changed end). while validating want show user allowed characters.
is possible allowed characters regex pattern.the expression dynamic configured in database can change time.due cannot show static message.
kindly suggest how allowed characters regex pattern.
thanks
regards,
karthik.k
out of box regex doesn't provide way pattern passed it. have couple of options.
1) create derived class stores input pattern , exposes property. cleanest , easiest approach.
2) when creating regex object, store off input pattern in field , use that. not clean eliminate need create new type.
ultimately i'm not sure how useful though. regular expression meaningless end user showing pattern won't them. example zip code can done \d{5}(-?\d{4})? meaningless everyone. might better expand end schema allow specify regex pattern , descriptive message explains pattern. allow use option 1 above user-friendly message.
michael taylor
http://www.michaeltaylorp3.net
Visual Studio Languages , .NET Framework > Visual C#
Comments
Post a Comment