>Is there a function in VFP that will work to replace a string between two delimits? Just as STREXTRACT() allows to extract between two delimits, to write the changed string back.
I think you are already following Sergey's good recommendation, but if in the future you want something similar that it is not XML (but you still have two delimiters) then you might be able to use regular expressions (depending what you want to do), for example:
clear
local loRE as 'VBScript.RegExp', lcString as String, lcNewText as String
lcString = '<TAG>this text will be replaced</TAG><SOMEOTHERTAG>This text remains unchanged</SOMEOTHERTAG><TAG>this text will be replaced too</TAG>'
lcNewText = 'this is the new text'
loRE = CreateObject('VBScript.RegExp')
with loRE as VBScript.RegExp
.Pattern = '(\<TAG\b[^\>]*\>)(.*?)(\<\/TAG\>)'
.Global = .t.
.IgnoreCase = .t.
if loRE.Test(lcString)
? .Replace(lcString, '$1' + lcNewText + '$3')
endif
endwith
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges