我在VSCode中编写了一个自定义片段来帮助我轻松定义自定义类方法。我需要能够输入一个字符串'formatted_like_this'并在某些地方使用正则表达式转换该字符串,使其变为'FormattedLikeThis'?
要在 php.json 中编写的自定义代码段:(请参阅“需要帮助 REGEX HERE”了解我遇到的问题)
"New Custom Class Method For Variable": {
"prefix": "contcmpffv",
"body": [
"protected $$1 = null;",
"public function get${NEED HELP WITH REGEX HERE}()",
"{",
"\t$0",
"}"
],
"description": "Controller Class Method Public Function For Variable"
}
我想要的工作流程: 1. 键入 contcmpffv 2. 当提示匹配代码段时按 Enter 2. 代码段提示是我 1 美元
所需输出(在提示输入 $1 时输入“test_input_string”):
protected $test_input_string = null;
public function getTestInputString()
{
*cursor resolves here (due to $0)*
}