[英]Regular Expression for a Positive Number between 0 and 12
我試過沒有運氣搜索互聯網上的正則表達式,檢查:
我需要將它放在這個特定代碼行的括號中
Regex rxValidHeightInches = new Regex();
任何幫助將不勝感激!
謝謝
這應該工作^(\\d|(1[0-2]))$
var rxValidHeightInches = new Regex("^(\\d|(1[0-2]))$");
試試這個吧。
(?<!-)(\b((1[01])|[1-9])\b)
它匹配1 - 9
或10
或11
。 始終排除負數。
釋
-Assert that it is impossible to match the regex below with the match ending at this position (negative lookbehind) «(?<!-)»
---Match the character “-” literally «-»
-Match the regular expression below and capture its match into backreference number 1 «(\b((1[01])|[1-9])\b)»
---Assert position at a word boundary «\b»
---Match the regular expression below and capture its match into backreference number 2 «((1[01])|[1-9])»
------Match either the regular expression below (attempting the next alternative only if this one fails) «(1[01])»
---------Match the regular expression below and capture its match into backreference number 3 «(1[01])»
------------Match the character “1” literally «1»
------------Match a single character present in the list “01” «[01]»
------Or match regular expression number 2 below (the entire group fails if this one fails to match) «[1-9]»
---------Match a single character in the range between “1” and “9” «[1-9]»
---Assert position at a word boundary «\b»
屏幕截圖
這一個包括0 - 12
(?<!-)(\b((1[0-2])|[0-9])\b)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.