开发者

Regex - Without Special Characters [closed]

开发者 https://www.devze.com 2023-03-22 21:25 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 2 years ag开发者_开发百科o.

Improve this question

I'm using regex to validate username

^[a-zA-Z]+\.[a-zA-Z]{4,10}^'

Unfortunately it doesn't affect if the the value contains special characters such as !@#$%^&*)(':;

I would glad to get some help for Regex that contains:

  • Alphanumeric only (a-zA-Z0-9)
  • Length between 4 - 10 characters.


The conditions you specified do not conform to the regexp you posted.

the regexp you posted ^[a-zA-Z]+\.[a-zA-Z]{4,10}^ is erroneous I guess, because of the ^ in the end, it will never be matched to any expression, if you want to match with the ^ at the end of the expression, you need to escape it like this \^. but ^ alone means "here is the start of the expression", while $ means "here is the end of the expression".

Even though, it denotes:

  • It starts with alpha (at least 1).
  • there must be a '.' period character.
  • Now there must be at least 4 alphas.

The regexp you need is really is:

^[a-zA-Z0-9]{4,10}$

This says:

  • It starts with alphanumeric.
  • There can be minimum of 4 and maximum of 10 of alphanumeric.
  • End of expression.


Try this:

^[a-zA-Z0-9]{4,10}$

0

精彩评论

暂无评论...
验证码 换一张
取 消