在word中,我試了很多方法想尋找在一個點之前的一個字或詞。
例如:
Give your IT freedom, flexi.bility, and control while reducing your IT overhead. Stop managing servers and get guaranteed 99.9% uptime. Move to the cloud on your terms. Connect your on-premises servers to Office 365 and run the latest d.d.version of Office side by side with a previous version while users transition. Stay in control and save time by managing your services easily in the admin center from any browser and by automating management tasks using PowerShell commands.
在這個例子里面我想要找到:
flexi. , 99., uptime., terms, d.d. , commands, 等等
原理就是尋找 “點” 前面的一個字直到有“一個”空格出現。
VBA 能寫出來嗎?
謝謝各位高手
uj5u.com熱心網友回復:
在Word 2003中開始記錄宏,手動完成所需功能,結束記錄宏,按Alt+F11鍵,查看剛才記錄的宏對應的VBA代碼。Selection.Find.ClearFormatting
With Selection.Find
.Text = "<[0-9A-Za-z]@."
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
Selection.Find.Execute
uj5u.com熱心網友回復:
謝謝樓上的高手。但是這個只是簡單的尋找開頭為0至9或者任意字母到點的運算式。
比如d.d.一次只能找到d.
有沒有辦法從右往左尋找空格?
uj5u.com熱心網友回復:
提醒:在字串查找問題域中,正則運算式不是萬能的;而有限狀態自動機是萬能的。參考《編譯原理》中的詞法分析和有限狀態自動機。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/129691.html
標籤:VBA
上一篇:請教高手 vb使用udp協議報錯 run-time error '2'
下一篇:vb與matlab混合編程問題
