【问题标题】:Capitalize doesn't lowercase trailing characters大写不小写尾随字符
【发布时间】:2020-06-11 19:57:30
【问题描述】:

我有这个sn-p:

{
  "Creates async dux modules": {
    "prefix": "dux-async",
    "body": [
      "// Duck module",
      "export const ${1:ModuleName}_REQUEST = \"${1}_REQUEST\";",
      "export const ${1}_SUCCESS = \"${1}_SUCCESS\";",
      "export const ${1}_ERROR = \"${1}_ERROR\";",
      "",
      "/**",
      " * State interface formodule",
      " */",
      "export interface ${1/(.*)/${1:/capitalize}/}State {",

当我进入我的 sn-p 时,我想写 FOO,当我关闭时,我希望将 sn-p 的最后一行转换为:

export interface FooState {

看起来大写不会小写尾随字符,所以我最终得到:

export interface FOOState

有没有办法保证第一个字符是大写的,其他的都是小写的?

【问题讨论】:

    标签: visual-studio-code code-snippets vscode-snippets


    【解决方案1】:
    "export interface ${1/(.)(.*)/${1:/capitalize}${2:/downcase}/}State {"
    

    有效。正如您所看到的,${1:/capitalize} 只会影响第一个字母 - 它对其他字母没有影响。因此,如果您想同时更改两者,不幸的是,您将不得不拆分您的正则表达式。

    【讨论】:

      猜你喜欢
      • 2015-02-20
      • 1970-01-01
      • 2018-01-14
      • 1970-01-01
      • 1970-01-01
      • 2011-01-16
      • 2016-01-25
      • 1970-01-01
      • 2014-05-04
      相关资源
      最近更新 更多