文章轉於:vs正規表示式應用[原創]
將所有的"..."字串替換成_t("..."),但是不能替換#include後面的字串
由於vs的正規表示式懶惰跟貪婪控制語法不明確,只好用2條表示式來實現
1. 將_t("...")轉換成"..."
_t\x28\x29
\12. 將"..."轉換成_t("..."),其中過濾掉#include 的字首
~(\#include:b)
_t(\1)
將兩步合成乙個巨集,新增到ide環境中.
option
strict off
option
explicit
offimports system
imports envdte
imports envdte80
imports envdte90
imports system.diagnostics
public
module recordingmodule
subreplace_str()
dte.windows.item(""
).activate()
'find and replace
dte.find.action
=vsfindaction.vsfindactionreplaceall
dte.find.findwhat ="
_t\x28\x29
"dte.find.replacewith ="
\1"dte.find.target
=vsfindtarget.vsfindtargetcurrentproject
dte.find.matchcase
=false
dte.find.matchwholeword
=false
dte.find.matchinhiddentext
=false
dte.find.patternsyntax
=vsfindpatternsyntax.vsfindpatternsyntaxregexpr
dte.find.resultslocation
=vsfindresultslocation.vsfindresultsnone
dte.find.action
=vsfindaction.vsfindactionreplaceall
dte.find.execute()
dte.windows.item(""
).activate()
'find and replace
dte.find.findwhat ="
~(\#include:b)
"dte.find.replacewith ="
_t(\1)
"dte.find.target
=vsfindtarget.vsfindtargetcurrentproject
dte.find.matchcase
=false
dte.find.matchwholeword
=false
dte.find.matchinhiddentext
=false
dte.find.patternsyntax
=vsfindpatternsyntax.vsfindpatternsyntaxregexpr
dte.find.resultslocation
=vsfindresultslocation.vsfindresultsnone
dte.find.action
=vsfindaction.vsfindactionreplaceall
dte.find.execute()
dte.windows.item(""
).close()
end sub
endmodule
字串替換(you替換成we)
編寫乙個c程式實現將字串中的所有 you 替換成 we input 輸入包含多行資料 每行資料是乙個字串,長度不超過1000 資料以eof結束 output 對於輸入的每一行,輸出替換後的字串 sample input you are what you dosample output we are ...
t字元替換成tab符
public static void main string args insert鍵 vk insert 45 home鍵 vk home 36 page up vk prior 33 pagedown vk next 34 end鍵 vk end 35 delete鍵 vk delete 46 ...
t字元替換成tab符
public static void main string args insert鍵 vk insert 45 home鍵 vk home 36 page up vk prior 33 pagedown vk next 34 end鍵 vk end 35 delete鍵 vk delete 46 ...