regex - 正则表达式 - 6 位或 9 位不小于或之间或更多的表达式
问题描述
我必须编写一个检测 6 位或 9 位的正则表达式 - 意思是:
ID 123 - it should not meet the regext as it is 3 digits
ID 1234 - it should not meet the regext as it is 4 digits
ID 12345 - it should not meet the regext as it is 5 digits
ID 123456 - it should meet the regex it is 6 digits <==========
ID 1234567 - it should not meet the regext as it is 7 digits
ID 12345678 - it should not meet the regext as it is 8 digits
ID 123456789 - it should meet the regext as it is 9 digits <==========
ID 1234567890 - it should not meet the regext as it is 10 digits
ID 12345678901 - it should not meet the regext as it is 11 digits
等等……你明白了吗?
谁能帮我解决这个问题的正则表达式?
解决方案
您可以尝试使用这种模式:
\b(\d{6}|\d{9})\b
推荐阅读
- python - 无法摆脱 y 轴上的前导零
- java - 保存时对 json 输入中的项目进行排序
- twitter - 删除 Twitter webhook 真的需要我拥有所有相关的消费者凭据吗?
- javascript - 事件监听器以防止在触摸鼠标水平滚动/后退按钮上刷新 javascript
- java - 变量的继承值为 0
- python - 为什么从模型生成的边界框保存的图像与原始图像相比分辨率要低得多
- r - 使用 R Shiny 创建问卷
- c++ - 如何通过代码中的麦克风在语音识别中使用pocketsphinx
- angular - 如何使用按钮触发 Facebook Messenger
- javascript - 使用wheelnav.js 如何将我的轮子连接到复制滑块