我需要用每行逗號后面的值替換單詞 'foo' - 例如'foo'變為'bar1'. 輸出應如下所示:this.load.image('bar1', bar1);
this.load.image('foo', bar1);
this.load.image('foo', bar2);
this.load.image('foo', bar3);
...
這怎么能用正則運算式來完成?
uj5u.com熱心網友回復:
搜索:
\('[^'] ',\s*([^\)] )\);\s*$
替代品
('$1', $1);
根據文本編輯器,它可能會\1代替$1. 我使用 sublime,所以我不確定使用的是哪種風格與代碼。
解釋:
\( - Match (
'[^'] ', - Match ', then all text until next ', next ' and the comma
\s* - Zero or more spaces
([^\)] ) - Capture group everything up to the next ). the group is important
\);\s*$ - Closing ); then any number of spaces and end of line.
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/414210.html
標籤:
上一篇:如何訂購行內視圖工具列圖示?
