正则表达式迷你速查:via:Somdev Sangwan
cat matches cat
ca+t matches caaaaaaaaaaaat but not ct
ca*t matches caaaaaaaaaaaat and also ct
ca{2,4} matches caat, caaat and caaaat
c(at)+ matches catatatatatat
c(at|orn) matches cat and corn
c[ea]t matches cat and cet
c[ea]+t matches caaaat and ceeet
c[A-C0-9]t matches cAt, cBt, cCt, c8t etc.
c.t matches cat, c&t, c2t (any char between c and t)
c.+t matches c3%x4t (any number of any chars)
c.*t matches c3%x4t and as well as ct
^a+cat matches aaacat in aaacat but not in bbaaacat
cat$ matches cat in aaacat but not in aaacats
^cat$ matches only and only this string i.e. cat
c\d+t matches c2784t
c\s+t matches c t
c\D+t matches cxxxt ca2t

被折叠的 条评论
为什么被折叠?



