블로그 이미지
이비그치면

태그목록

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

calendar

1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

WORD VBA - 번체자 제거하고 병음만 남기기

2016. 12. 23. 15:27 | Posted by 이비그치면

아래 중국어(한어) 번체자(병음)으로 되어있는 문자열에서

병음만 남기는 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