在VS Code中,用于创建user defined snippets的文档中提到了一些Grammar,其中包括/upcase
,/downcase
和/capitalize
的选项,但是我可以t弄清楚如何使用它。
我正在Mac上使用最新版本的VS Code:Version 1.25.0
。
此代码段似乎应在输入占位符并单击tab后将占位符的值转换为大写和小写,但这不是:
"test": {
"prefix": "test",
"body": "${1} -> ${1:/upcase} ${1:/downcase}"
},
test
键入Asdf
会导致:
Asdf -> Asdf Asdf
点击选项卡可获得以下结果:
Asdf -> ASDF asdf
asdf -> asdf asdf
答案 0 :(得分:5)
尝试一下:
"test": {
"prefix": "test",
// "body": "${1} -> ${1/(.*)/${1:/upcase}/} > ${1/(.*)/${1:/downcase}/}"
// simpler version below works too
"body": "${1} -> ${1/(.*)/${1:/upcase} ${1:/downcase}/}"
}
答案 1 :(得分:2)
解决方案:
content1 = soup.find_all('div', class_='slot type-post type-order-1')
content2 = soup.find_all('div', class_='slot type-post type-order-2')
for contents in content1:
title1 = contents.find('h3', class_='post-title entry-title card-title').text
link1 = contents.h3.a['href']
print(title1)
print(link1)
for content in content2:
title2 = content.find('h3', class_='post-title entry-title card-title').text
link2 = content.h3.a['href']
print(title2)
print(link2)
结果:
"test": {
"prefix": "test",
"body": "$1 ${1/(.*)/${1:/upcase}/} -> ${1/(.*)/${1:/downcase}/} -> ${1/(.*)/${1:/capitalize}/}"
}
答案 2 :(得分:0)
供参考:
EBNF文档中的整数是指RegExp组而不是Tabstop引用,因此应该可以工作:
"test": {
"prefix": "test",
"body": "${1} -> ${1/(Asdf)/${1:/upcase}/} ${1/(Asdf)/${1:/downcase}/}"
}
答案 3 :(得分:0)
请参见手册snippets
部分的variable transforms部分。