1
A
回答
1
我認爲這是一件事,但顯然不是。爲什麼一個人會這麼想?
如果你看起來真的很快,它確實欺騙了你。但運營商的實施並不完整,將會失敗。
以下範圍的量詞/運營商的認可:
{n} Match the preceding exactly n times
{n,} Match the preceding at least n times
{n,m} Match the preceding at least n but not more than m times
{n,}? Match the preceding at least n times, but as few times as possible.
{n,m}? Match the preceding between n and m times, but as few times as possible.
中與使用操作必須設置{n
齊全,應有盡有以下,m}
是可選的。
正確使用量詞/運算符的示例。
"12345".match(/\d{3}/); // => matches '123'
"12345".match(/\d{5,}/); // => matches '12345', FAILS on 1234
"12345".match(/\d{1,4}/); // => matches '1234'
"12345".match(/\d{2,}?/); // => matches '12'
"12345".match(/\d{2,4}?/); // => matches '12'
2
量詞{n1,n2}
是一個有效的JavaScript正則表達式量詞,它將匹配n1到n2次(含)。
但是,{,n}
確實不是代表量化因爲需要最小限制。有關語法制作和規則,請參見部分15.10.2.7 Quantifier。
以下所有介紹的有效範圍量詞:
/\d{3,5}/.test('12') // false
/\d{3,5}/.test('1234') // true
/\d{3,5}/.test('123456') // false
在另一方面,下面的正則表達式不創建一個量詞。相反,生產被解析成一個文本,沒有特別的含義:
/a{,5}b/.test('a{,5}b') // true, at least in Chrome and IE
相關問題
- 1. 妄想寶石恢復
- 2. 我妄想Html編碼?
- 3. 妄想用belongs_to的
- 4. Javascript RegExp和邊界
- 5. TextArea MaxLength - 支持還是不支持?
- 6. Selenium可以支持Hibernate還是Spring?
- 7. SOA服務邊界和生產支持
- 8. GraphHopper是否支持動態邊權重?
- 9. Python重新模塊支持單詞邊界(\ b)嗎?
- 10. jBPM6不支持邊界定時器
- 11. 邊界半徑在歌劇不支持
- 12. SQLite在C和支持REGEXP
- 13. 我應該使用VS 2008重構支持還是購買ReSharper?
- 14. MATLAB保持複雜矩陣的邊界
- 15. CSS支持 - 複選框
- 16. 是否可以StringTemplate支持可重用
- 17. .NET中支持什麼橢圓曲線?我可以定義自己的曲線,還是重複SEC標準?
- 18. 我可以同時設置邊界左邊界和右邊界邊界嗎?
- 19. 重載可選陣列支持 - Java
- 20. 支持兩個JPA實現是可行的還是推薦的?
- 21. Internet Explorer 11是否支持邊界圖像?
- 22. Svelte是否支持複選框綁定?
- 23. HTML支持JS支持
- 24. 防止Fabric JS對象可見邊界
- 25. 是gfortran還是g95都支持?
- 26. 複製邊界
- 27. java中的ECMA 262/Perl 5 regexp支持
- 28. D3.js中的邊界框
- 29. Vim是否支持「可變選項卡」?
- 30. 我們想支持cakephp的國際化
我明白,maxbound是可選的,這正是我所想的。 – user2958725