我想用(map["someKey"] as num).toDouble()
替换 map["someKey"] as double
,但我无法正确使用正则表达式。 有了解更多关于正则表达式的人可以告诉我在VSCode中找到什么并替换为什么吗? 我尝试过 ([a-zA-Z0-9]*) as double
并将其替换为 ($1 as num).toDouble()
,但这行不通。
我想用(map["someKey"] as num).toDouble()
替换 map["someKey"] as double
,但我无法正确使用正则表达式。 有了解更多关于正则表达式的人可以告诉我在VSCode中找到什么并替换为什么吗? 我尝试过 ([a-zA-Z0-9]*) as double
并将其替换为 ($1 as num).toDouble()
,但这行不通。
使用
(\w+\["[^"]+"\]) as double
请查看正则表达式验证。使用($1 as num).toDouble()
进行替换。
说明
--------------------------------------------------------------------------------
( group and capture to \1:
--------------------------------------------------------------------------------
\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 \1
--------------------------------------------------------------------------------
as double ' as double'
map["someKey"]
总是一个字典对象吗? - Wiktor Stribiżewvar
然后想用map["someKey"]
更精确,但是我忘记把它放在第一位了。 - PlutoHDDev