Reputation: 51
Goal: In VS Code, I'm trying to create a snippet that takes "FooBar" and outputs "FooBar fooBar".
Current Code: I have "$1 ${1:camelcase}" for the body of my snippet. But it outputs "FooBar FooBar." I have tried a number of other options but none seem to work. I know it's probably something relatively simple that I'm missing.
Question: What is the correct syntax to make only the first letter of my variable name become lowercase?
Upvotes: 1
Views: 1204
Reputation: 182141
All you really need is the first letter and ignore the rest:
"$1 ${1/(.)/${1:/downcase}/}",
or using the newer camelcase
option:
"$1 ${1/(.*)/${1:/camelcase}/}",
Upvotes: 4
Reputation: 28763
you just split the string in two parts
${1/(.)(.*)/${1:/downcase}${2}/}
Upvotes: 0