2012-05-23 49 views

回答

4
(?:v) # matches 'v' this is a non-capturing group, not a lookbehind 
.* # matches 'dd' 
(?:v) # matches 'v' this is a non-capturing group, not a lookahead 

非捕獲組還參加了比賽。也許你想要一個超前/後面?但Javascript不支持向後看。

3
"aaavddv".match(/(?:v)(.*)(?:v)/)[1] 

整場比賽是正確vddv但如果你想只匹配dd您需要使用捕獲組(看看元素[1]

3

/(?:v).*(?:v)/指定表達式v(字符數)v