是否有一些函数/算法来创建regexp的文本描述?例如
([a-z]+)
- > “仅限小写字母” ([0-9]{1,40})
- > “仅限1到40位数字” ([a-z])([0-9]{5})
- > “小写字母后跟5位数” 等
答案 0 :(得分:1)
我爱RegExBuddy。
对于上面([a-z]+)
的例子,它给出了
Match the regular expression below and capture its match into backreference number 1 «([a-z]+)»
Match a single character in the range between “a” and “z” «[a-z]+»
Between one and unlimited times, as many times as possible, giving back as needed (greedy) «+»
Match the character “ ” literally « »
和
([a-z])([0-9]{5})
它解释为
Match the regular expression below and capture its match into backreference number 1 «([a-z])»
Match a single character in the range between “a” and “z” «[a-z]»
Match the regular expression below and capture its match into backreference number 2 «([0-9]{5})»
Match a single character in the range between “0” and “9” «[0-9]{5}»
Exactly 5 times «{5}»
我觉得测试/创建RegExes非常棒。