VSCode 使用正则表达式组替换正则表达式

VSCode regex replace using regex group

我想用 (map["someKey"] as num).toDouble() 替换 map["someKey"] as double,但我无法让正则表达式正常工作。对正则表达式了解更多的人可以告诉我在 VSCode 中的查找和替换中放什么吗? 我试过 ([a-zA-Z0-9]*) as double 并将其替换为 ( as num).toDouble(),但这不起作用。

使用

(\w+\["[^"]+"\]) as double

参见regex proof替换为 ( as num).toDouble().

解释

--------------------------------------------------------------------------------
  (                        group and capture to :
--------------------------------------------------------------------------------
    \w+                      word characters (a-z, A-Z, 0-9, _) (1 or
                             more times (matching the most amount
                             possible))
--------------------------------------------------------------------------------
    \[                       '['
--------------------------------------------------------------------------------
    "                        '"'
--------------------------------------------------------------------------------
    [^"]+                    any character except: '"' (1 or more
                             times (matching the most amount
                             possible))
--------------------------------------------------------------------------------
    "\]                       '"]'
--------------------------------------------------------------------------------
  )                        end of 
--------------------------------------------------------------------------------
   as double               ' as double'