Regular Expression for field must contain at least 2 non-space alphanumeric characters

一个人想着一个人 提交于 2021-02-05 07:56:06

问题


Rule: field must contain at least 2 non-space alphanumeric characters.

please any one can guide us how to write the regular expression

thanks in advance....


回答1:


Match one alphanumeric character followed by zero or more characters followed by another alphanumeric character:

\w.*\w

If the validation automatically adds ^ and $, you have to match the characters before and after also:

.*\w.*\w.*

The \w code matches A-Z, a-z, 0-9 and _. If you have a different definition for aplhanumeric characters, you can use a set of characters instead, for example:

[A-Za-z0-9].*[A-Za-z0-9]


来源:https://stackoverflow.com/questions/2244516/regular-expression-for-field-must-contain-at-least-2-non-space-alphanumeric-char

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!