Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

regex to validate username

Last post 08-11-2008, 10:51 AM by ddrudik. 3 replies.
Sort Posts: Previous Next
  •  08-11-2008, 5:36 AM 45206

    regex to validate username

    Hi, i've been searching frenzy for a regex that validates a username that may contain a-z A-Z 0-9 . - and _ in ASP.NET

    The catch is that this username is to be part of the url so the username may not contain _.- in the begining of the name or in the end of the name, and _.- may be typed together like e.x cool._steve, greate-_-pete and so on.

    can someone help me with this please

  •  08-11-2008, 9:24 AM 45214 in reply to 45206

    Re: regex to validate username

    Possibly:

    ^(?![._-].*|.*[._-]$)[\w.-]+$


  •  08-11-2008, 10:37 AM 45215 in reply to 45214

    Re: regex to validate username

    thanks for your reply, allthough i noticed that i forgot to type "not" what i was looking for is a the same regex that don't allow the different combinations of .-_ in a row.
     

  •  08-11-2008, 10:51 AM 45216 in reply to 45215

    Re: regex to validate username

    ^(?![._-].*|.*[._-]$|.*[._-]{2})[\w.-]+$
View as RSS news feed in XML