Hi,
Do any one of you know the regular expression for user name that allows special characters(. and _) but not at the end of the string. For example, it should not allow the user to enter "john123." or "John_". But the otherwise is acceptable. For example, the user names "john.harlow" or "john_harlow".
Thanks
Shwetha
Loading

VulpesRank #55 · 29.2K reputationPosted Nov 19, 2011, 1:50 AM EST
string regexp = @"^(?=.*[^_\.\(\)]+$)[A-Za-z0-9_\.\(\)]+$";
shwetha sonar5 reputationPosted Nov 19, 2011, 12:58 PM EST
Thanks for the reply.
But, the suggested expression does not meet the requirement. It is not allowing me to enter the special characters I want (ie . and _). Also, majorly it does not accept any string for the user name. For example: only aplhabets or aplhanumeric.
Regards
Shwetha
VulpesRank #55 · 29.2K reputationPosted Nov 19, 2011, 1:36 PM EST
VulpesRank #55 · 29.2K reputationPosted Nov 20, 2011, 12:12 AM EST
You could therefore simplify the regular expression to:
string regexp = @".*[^_\.]$";
shwetha sonar5 reputationPosted Nov 28, 2011, 2:46 AM EST
Thanks for the reply.
The suggested regular expression does not work. It still does not meet the requirements.
Shwetha