0

使用下面的代码,我想将 $2 中的变量转换为小写,但我不能让它工作。

    "Build Model": {
        "prefix": "mod",
        "body": [
            "import '${1:../backend.dart}';",
            "",
            "class ${2:Class} extends ManagedObject<_$2> implements _$2 {}",
            "${2/(*)/${2:/downcase}/}",
            "${2:/downcase}" //would be nice to be able to do this
            "@Table(name: \"${2/(*)/${2:/downcase}/}\")",
            "class _$2 {",
            "@Column(primaryKey: true, autoincrement: true, indexed: true)",
            "int id;",
            "$3",
            "}",
            ""
        ],
        "description": "Build a data model"
    },
4

1 回答 1

0

我通过如下更改使其工作:

"${2/([a-zA-Z]*)/${1:/downcase}/}",

这里 $1 指的是这个表达式中的变量(即 $2),而不是上面的 $1 变量。

编辑:请参阅下面有关使用 (.*) 的答案。

于 2019-11-05T23:19:50.567 回答