我想使用 gregexpr 函数来查找字符串中子字符串的开始和结束位置。该函数在控制台中运行良好,但我无法访问起始位置或字符串长度的结果:
g <- gregexpr("e", "cheese")
g
[[1]]
[1] 3 4 6
attr(,"match.length")
[1] 1 1 1
attr(,"index.type")
[1] "chars"
attr(,"useBytes")
[1] TRUE
Run Code Online (Sandbox Code Playgroud)
g[[1]][1]仅显示第一个值 (3),但我需要创建一个包含起始位置和长度的所有值的向量。谢谢。
我正在努力让代码片段在带有四开文件的 vscode 中工作。我已经遵循了所有步骤,但我对此感到困惑。
quarto.json。我的片段如下所示:{
"Create NOTES section and place cursor inside": {
"prefix": "nn",
"body": [
"<!-- BEGIN NOTES -->\n\n$1\n\n<!-- END NOTES -->"
],
"description": "Create Notes section and place cursor inside"
}
}
Run Code Online (Sandbox Code Playgroud)
settings.json文件有以下内容: "[quarto]": {
"editor.quickSuggestions": {
"other": true,
"comments": true,
"strings": true
}
}
Run Code Online (Sandbox Code Playgroud)
但是,在四开文件中,当我按 时,不会出现任何建议nn。
注意,Quarto 文件的扩展名不是.qmd,.Quarto但 vscode 将该文件识别为文件quarto,因为 (i) 这出现在窗口的页脚中.qmd,并且 (ii)quarto.json当我配置用户片段时会自动出现一个文件。