I'm parsing a set of questionnaires that don't lend themselves to easy
parsing, so I'm searching through a text file (saved from an RTF file,
saved from a Crystal Report) looking for the question, and then
figuring out the answer. Sometimes, though, there are too many, or too
few, spaces, so I had to use RegExp.fll. My first pass at this used
LEN() on the _CLIPTEXT and then figured the location where the answer
had to be: the RegExp pass was a bit more complicated.

LPARAMETERS oFoxCode
LOCAL lcCRLF, lcClip, lcRetVal

oFoxCode.ValueType = "V"

lcCRLF = CHR(13) + CHR(10)

lcClip = _CLIPTEXT

*!* Change spaces to escape
DO WHILE " "$lcClip
        lcClip = STRTRAN(lcClip, " ", "\s")
ENDdo

*!* Combine escaped spaces
DO WHILE "\s\s"$lcClip
        lcClip = STRTRAN(lcClip, "\s\s", "\s")
ENDDO

*!* For each space, allow for zero or more
lcClip = STRTRAN(lcClip, "\s", "\s*")

*!* Escape periods
lcClip = STRTRAN(lcClip, ".", "\.")

*!* In the first line, don't save the backref, for efficiency
lcRetVal = CHR(9) + [IF RegExp(lcLine, "] + lcClip + [(?:.*)")] + lcCRLF
lcRetVal = lcRetVal + CHR(9) + CHR(9) ;
        + [lcS~ = RegExp(lcLine, "] + lcClip + [(.*)", 1, "\1")] + lcCRLF
lcRetVal = lcRetVal + CHR(9) + [ENDIF]

RETURN lcRetVal


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to