troubleshooting Question

Need Regular Expression to strip RTF off of field value

Avatar of incrediblejohn
incrediblejohn asked on
Microsoft Access
4 Comments1 Solution1130 ViewsLast Modified:
We have SQL Server storing rtf formatting in the form of text string. For quick queries, reports, we don't want to use an rtf control, just strip off the formatting and show the text. I can't seem to get the Regular Expression correct to do this:

Dim buf2 As String
buf2 = "{\rtf1\ansi\deff0{\fonttbl{\f0\froman Tms Rmn;}{\f1\froman Times New Roman;}}"
buf2 = buf2 & "{\colortbl\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;"
buf2 = buf2 & "\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255"
buf2 = buf2 & "\green255\blue0;\red255\green255\blue255;\red0\green0\blue127;\red0\green127\"
buf2 = buf2 & "blue127;\red0\green127\blue0;\red127\green0\blue127;\red127\green0\blue0;\red127\"
buf2 = buf2 & "green127\blue0;\red127\green127\blue127;\red192\green192\blue192}{\info"
buf2 = buf2 & "{\creatim\yr2004\mo6\dy28\hr10\min41\sec1}{\version1}{\vern262367}}\"
buf2 = buf2 & "paperw12240\paperh15840\margl360\margr0\margt239\margb0\deftab720\pard\ql"
buf2 = buf2 & "{\f1\fs20\cf0\up0\dn0 06/28/04 Goldie nds lic# and original date of iss liz}"
buf2 = buf2 & "{\par}\pard\ql{\f1\fs20\cf0\up0\dn0 PerRem|??:|  EmplStat|EPART-OTH|}{\par}\pard\ql}"

Dim regexp As VBScript_RegExp_55.regexp
Set regexp = New VBScript_RegExp_55.regexp
regexp.Global = True
regexp.IgnoreCase = True
Dim buf As String

regexp.Pattern = "(\{\\f\d*)\\([^;]+;)"

Dim str As String

str = regexp.Replace(buf2, "")

MsgBox str
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros