string manipulation question
Robert Haussmann
haussma at nextdimension.net
Fri Dec 10 18:04:40 PST 2004
> | I'm sure there is probably a very easy way to do the
> | following, but it eludes me at the moment. How
> | can I take a string, and replace every instance of
> | one character (a single quotation mark) with two
> | characters (two single quotes)?
> |
> | In other words:
> | O'Brian becomes O''Brian
> | O'Brian's becomes O''Brian''s
>
> I use this subroutine to modify the string held in Misc so
> all backslashes in it are escaped with another backslash
> for screen display purposes.
>
> DXlate If:
> Then: ' Escape backslash characters with a backslash
> for display
> Then: Misc1 = Misc { "" ; Misc = "" ; cnt = "1"
> DXlate1 If:
> Then: Misc = Misc & mid(Misc1,cnt,"1")
> If: mid(Misc1,cnt,"1") eq BackSlash
> Then: Misc = Misc { BackSlash
> If: cnt lt len(Misc1)
> Then: cnt = cnt + "1" ; goto DXlate1
> Then: return
>
> Modify it to do a similar thing for single quotes.
>
Thanks Bob--that's the way I originally set out to get this
to work, but ended up with an endless loop. Your code works
perfectly.
Bob
More information about the Filepro-list
mailing list