Html5输入模式 [英] Html5 input pattern

查看:114
本文介绍了Html5输入模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这种模式。*?[az]([az])([az])([az])。*?(\ s +)(\d +)来自某个在线生成器,但它无法正常工作。

I have this pattern .*?[a-z]([a-z])([a-z])([a-z]).*?(\s+)(\d+) from some online generator but it's not working.

我需要允许的模式:

最小3个字符长度字符串,下一个单独空格,下一个最小1个字符整数[abc 1]或相同但不同顺序最小1个字符整数,下一个单独空格和下一个最小3个字符长度字符串[3 gtf] 。

"minimum 3 char length string, next single space, and next minimum 1 char integer" [abc 1] or the same but in different order "minimum 1 char integer, next single space, and next minimum 3 char length string" [3 gtf].

谢谢。

推荐答案

试试这个:

\d+\s\w{3,}|\w{3,}\s\d+

它匹配:


  1. 一个或多个数字( \d + ),后跟一个空格( \s ),后跟三个或更多单词字符( \w {3,} )(这是[a-zA-Z0-9],你可以用[a]替换这个部分-zA-Z]如果你愿意的话。

  2. 三个或更多单词字符(这是[a-zA-Z0-9],你可以如果你愿意,用[a-zA-Z]替换这个部分,然后是一个空格,后跟一个或多个数字。

  1. One or more digits (\d+), followed by a single whitespace (\s), followed by three or more word characters (\w{3,}) (this is [a-zA-Z0-9], you can replace this part with [a-zA-Z] if you'd like).
  2. Three or more word characters (this is [a-zA-Z0-9], you can replace this part with [a-zA-Z] if you'd like), followed by a single whitespace, followed by one or more digits.

Regex101

这篇关于Html5输入模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆