컴퓨터/기타
WORD VBA - 번체자 제거하고 병음만 남기기
이비그치면
2016. 12. 23. 15:27
아래 중국어(한어) 번체자(병음)으로 되어있는 문자열에서
병음만 남기는 VBA script이다
您(nín)是(shì)老(lǎo)师(shī)吗(ma) ==> nínshìlǎoshīma
Sub xxxx() Dim regEx, Match, Matches Dim sPinyin As String Set regEx = New RegExp sHan = "您(nín)是(shì)老(lǎo)师(shī)吗(ma)" regEx.Pattern = "\((.*?)\)" '-- 괄호속 문자 찾기(non-greedy) regEx.IgnoreCase = True regEx.Global = True Set Matches = regEx.Execute(sHan) sPinyin = "" For Each m In Matches sPinyin = sPinyin + m.SubMatches(0) Next Debug.Print sPinyin End Sub