我前段时间做了一个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