标签: javascript regex
/(?:(?:^|.*;)\s*key\s*\=\s*([^;]*).*$)|^.*$/
我有这个RegExp可以获取cookie中的密钥,但我不知道是什么
(?:^|.*)表示我的意思是?:在javascript中的含义
(?:^|.*)
?:
答案 0 :(得分:2)
()会定义capturing group。 (?:)会将其non-capturing。
()
(?:)
Reference - What does this regex mean?
答案 1 :(得分:2)
它被称为Non-Capturing Groups: (?: … )
Non-Capturing Groups: (?: … )
例如(?:Mofei|Zhu)匹配Mofei或Zhu - 但未捕获该名称。
(?:Mofei|Zhu)
Mofei
Zhu