【发布时间】:2020-11-30 20:20:12
【问题描述】:
我有以下字符向量:
text_test <- c(
"\\name{function_name}",
"\\title{function_title}",
"The function \\name{function_name} is used somewhere"
)
我想提取花括号之间的单词,即function_name 和function_title。我试过这个:
stringr::str_extract(text_test, '\\{[^\\}]*\\}')
但这也会提取花括号。
我有两个问题:
-
如何修改此正则表达式以排除花括号?
-
如何在基础 R 中做到这一点?
【问题讨论】:
-
这能回答你的问题吗? R : get string between braces { }