问题

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

I need pattern which allow:

"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].

Thanks.

回答1:

Try this one:

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

It either matches:

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).

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

回答2:

The following expression should do what you describe:

[a-z]{3,}\s\d+|\d+\s[a-z]{3,}

Some notes:

The {3,} construct allows you to specify repetitions within a given range. In general, it's {min,max}, but you can leave out either min or (as here) max to have an open-ended range. You can also specify an exact number of repeats by specifying a single number, e.g. {99}.

The expression is essentially two complete expressions switched with alternation. Regular expressions don't allow you to say "exactly these things, in any order".

I've used [a-z] to match the characters in the non-numeric part, as this is what you did in your original example.

来源:https://stackoverflow.com/questions/32970438/html5-input-pattern

html input patten,Html5 input pattern相关推荐

  1. html5 规定输入字段,HTML5 Input属性详解

    本篇教程探讨了HTML5 Input属性详解,希望阅读本篇文章以后大家有所收获,帮助大家HTML5+CSS3从入门到精通 . < value 属性 value 属性规定输入字段的初始值: rea ...

  2. HTML5 input placeholder 颜色 改动

    David Murdoch:Chrome支持input=[type=text]占位文本属性,但下列CSS样式却不起作用: CSS input[placeholder], [placeholder], ...

  3. HTML5 input 类型

    HTML5 Input 类型 HTML 4.01 与 HTML 5 之间的差异 以下类型是 HTML5 中的新类型:color, date, datetime, datetime-local, mon ...

  4. 使用CSS修改HTML5 input placeholder颜色

    有三种实现方式:伪元素(pseudo-elements).伪类( pseudo-classes)和Notihing. WebKit和Blink(Safari,Google Chrome, Opera1 ...

  5. HTML5 input()标签

    一.标签定义 1.<input> 标签规定了用户可以在其中输入数据的输入字段. 2.输入类型是由 type 属性定义. 二.input的参数 <input type="类型 ...

  6. [html] 说说你对HTML5中pattern属性的理解

    [html] 说说你对HTML5中pattern属性的理解 好像是判断input在输入时按下tab键跳转到下一个input的优先级 个人简介 我是歌谣,欢迎和大家一起交流前后端知识.放弃很容易, 但坚 ...

  7. input 强大的 input 标签

    2019独角兽企业重金招聘Python工程师标准>>> <input type="color"value="#6fbc6d"> & ...

  8. html input日期值,input标签设置时间值

    研究了两天javascript日期相关的内容,一句话总结:"浏览器可以用上十万年,因为javascript支持的时间范围就是这么长". 通过实验来看,比较好用的是type=&quo ...

  9. input css年月日,input标签的type为date,显示的日期格式样式更改

    这个///是改不了---的,这是谷哥自带的功能样式,只能改颜色背景色等,如果要那种效果可以用日历插件 有个取巧的方法,一个不能改的input覆盖在input type="date" ...

最新文章

  1. 自学linux指令分析-cat
  2. (十二)进一步掌握STVD/COSMIC
  3. [渝粤教育] 厦门理工学院 机械设计 参考 资料
  4. 设置 Linux 的 LD_LIBRARY_PATH 变量
  5. Elasticsearch 5.6.5 安装head插件
  6. php factory interface,PHP设计模式之工厂方法*解读
  7. ubuntu安装matlab空间不足,Ubuntu安装Matlab方法及命令
  8. Nginx的启动阶段讲解
  9. ipmitool介绍_ipmitool命令行使用详解
  10. OpenShift 4 - DevSecOps Workshop (12) - 用CodeReady Workspace编辑提交应用代码
  11. java新手笔记16 面积
  12. MIT 6.824 学习笔记(一)--- RPC 详解
  13. Google笔记本迈向烂笔头
  14. [北航软工]技术规格说明书
  15. Arduino教程六—DS1302时钟模块
  16. 视易linux进图形界面,视易KTV点歌机系统安装说明.ppt
  17. 【机器学习基石】感知机模型+PLA(二)
  18. JS设置select下拉框默认选中
  19. 华为最美小姐姐,被外派墨西哥后...
  20. 【No JSON object could be decoded】问题解决

热门文章

  1. 大学计算机专业实训课,《大学计算机课程》实验报告1-.doc
  2. [准连续泵浦被动调Q激光器速率方程求解
  3. [威客任务]¥800.00 JS实现网站联动三级选项
  4. 手动清楚smsc病毒
  5. 【爬虫】用Selenium+PyQuery爬取京东商城
  6. 厉害了时代中国!见过买房的,没见过用“手机”买房的
  7. verilog中的inout端口与三态门、高阻态的使用
  8. linux+多个字符分割字符串数组中,String的split()方法可以将字符串按照特定的分隔符拆分成字符串数组...
  9. uni-app写app点击app的分享,分享至微信,在微信中点击分享卡片打开小程序并跳转至相应页面
  10. 多多客商业版周更新:插件市场全面升级为应用商店