VSCode片段,如何编写正则表达式以将由下划线分隔的小写字符串转换为CamelCase?

问题描述 投票:1回答:1

我在VSCode中编写了一个自定义代码段,以帮助我轻松定义自定义类方法。我需要能够输入字符串'formatted_like_this',并让regex在某些地方转换该字符串,使其变为'FormattedLikeThis'?

将在php.json中编写的自定义代码段:(请参阅“我需要在这里输入正则表达式”)

"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.键入contcmpffv2.提示匹配代码段时,按Enter键2.代码段提示我是$ 1

所需的输出(在提示您输入$ 1时输入“ test_input_string”:]

protected $test_input_string = null;
public function getTestInputString()
{
    *cursor resolves here (due to $0)*
}

我正在VSCode中编写自定义代码段,以帮助我轻松定义自定义类方法。我需要能够输入一个字符串'formatted_like_this'并让regex在某些情况下将该字符串转换为...

json regex visual-studio-code camelcasing vscode-snippets
1个回答
0
投票

尝试:

© www.soinside.com 2019 - 2024. All rights reserved.