我前段時間做了一個REGEX模式,我不記得它的意思。對我來說,這是一個只寫語言:)解釋這個特定的REGEX
這裏是正則表達式:
"(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$"
我需要知道,用簡單的英語,這是什麼意思。
我前段時間做了一個REGEX模式,我不記得它的意思。對我來說,這是一個只寫語言:)解釋這個特定的REGEX
這裏是正則表達式:
"(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$"
我需要知道,用簡單的英語,這是什麼意思。
(?!^[0-9]*$)
不長僅匹配數字,
(?!^[a-zA-Z]*$)
不匹配字母,
^([a-zA-Z0-9]{8,10})$
匹配的字母和數字8到10個字符。
使用類似expresso的東西來分析它。
RegexBuddy說了這樣的(!?!):
(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{8,10})$
Options:^and $ match at line breaks
Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!^[0-9]*$)»
Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
Match a single character in the range between 「0」 and 「9」 «[0-9]*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
Assert position at the end of a line (at the end of the string or before a line break character) «$»
Assert that it is impossible to match the regex below starting at this position (negative lookahead) «(?!^[a-zA-Z]*$)»
Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
Match a single character present in the list below «[a-zA-Z]*»
Between zero and unlimited times, as many times as possible, giving back as needed (greedy) «*»
A character in the range between 「a」 and 「z」 «a-z»
A character in the range between 「A」 and 「Z」 «A-Z»
Assert position at the end of a line (at the end of the string or before a line break character) «$»
Assert position at the beginning of a line (at beginning of the string or after a line break character) «^»
Match the regular expression below and capture its match into backreference number 1 «([a-zA-Z0-9]{8,10})»
Match a single character present in the list below «[a-zA-Z0-9]{8,10}»
Between 8 and 10 times, as many times as possible, giving back as needed (greedy) «{8,10}»
A character in the range between 「a」 and 「z」 «a-z»
A character in the range between 「A」 and 「Z」 «A-Z»
A character in the range between 「0」 and 「9」 «0-9»
Assert position at the end of a line (at the end of the string or before a line break character) «$»
如果你不能讀正則表達式,你不應該寫它們。 – Tomalak 2009-07-13 10:24:41
如果你從來沒有學過正則表達式,並且你突然維護包含它們的代碼,那麼這是一個合理的問題。 – Mark 2009-07-13 12:37:13