我想替換map["someKey"] as double為(map["someKey"] as num).toDouble(),但我無法讓正則運算式正常作業。了解更多關于正則運算式的人可以告訴我在 VSCode 中的查找和替換中放置什么嗎?我已經嘗試([a-zA-Z0-9]*) as double并將其替換為($1 as num).toDouble(),但這不起作用。
uj5u.com熱心網友回復:
采用
(\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'
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/444356.html
