本帖最后由 作者 于 2004-6-27 19:19:41 编辑
这些就是大部分格式符,另外还有的内容就是缩进格式和制表符格式:
以下函数已经改进支持缩进和制表符格式,还做了改进,不必做控件引用。 - Public Function GetMTextUnformatString(MTextString As String) As String
- Dim s As String
- Dim RE As Object
- Set RE = ThisDrawing.Application.GetInterfaceObject("Vbscript.RegExp")
-
- RE.IgnoreCase = False
- RE.Global = True
- s = MTextString
-
- '替换\\字符
- RE.Pattern = "\\\"
- s = RE.Replace(s, Chr(1))
- '替换\{字符
- RE.Pattern = "\\{"
- s = RE.Replace(s, Chr(2))
- '替换\}字符
- RE.Pattern = "\\}"
- s = RE.Replace(s, Chr(3))
-
- '删除段落缩进格式
- RE.Pattern = "\\pi(.[^;]*);"
- s = RE.Replace(s, "")
- '删除制表符格式
- RE.Pattern = "\\pt(.[^;]*);"
- s = RE.Replace(s, "")
- '删除堆迭格式
- RE.Pattern = "\\S(.[^;]*)(\^|#|\\)(.[^;]*);"
- s = RE.Replace(s, "$1$3")
- '删除字体、颜色、字高、字距、倾斜、字宽、对齐格式
- RE.Pattern = "(
|