> str_extract("hello world (lalala)","(?=\\().+?(?=\\))")
"(lalala"
> str_extract("hello world (lalala)","(?=\\().+?(?<=\\))")
"(lalala)"
> str_extract("hello world (lalala)","(?<=\\().+?(?=\\))")
[1] "lalala"
简写 | 描述 | 含义 |
---|---|---|
?=... |
正预测先行断言 | 捕获前面的 |
?<= ... |
正回顾后发断言 | 捕获后面的 |