Skip to content

Instantly share code, notes, and snippets.

@bxb100
Last active April 16, 2022 14:17
Show Gist options
  • Save bxb100/c1e9e7fb40905304338bce73021933cc to your computer and use it in GitHub Desktop.
Save bxb100/c1e9e7fb40905304338bce73021933cc to your computer and use it in GitHub Desktop.
常见的正则
限制输入字符串规则:
1.仅支持输入中英文 数字 连字符- 空格字符
2.且不能全为空格字符
  1. ^(?!\s+$)[0-9a-zA-Z\\u4e00-\\u9fa5\-\s]+$
  2. ^[\u4e00-\u9fa5\d\w- ]*[\u4e00-\u9fa5\d\w-]+[\u4e00-\u9fa5\d\w- ]*$
  3. ^(?=[ ]*[\S]+)[\u4E00-\u9FFF0-9a-zA-Z- ]+$

正则做不到后置/前置动态字段的时候, 必须是定长字段


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment