Board index » cppbuilder » StringReplace Oddities

StringReplace Oddities


2006-09-01 12:02:23 AM
cppbuilder102
1) StringReplace(lots_of_rtf_text,"\\par \r\n\\par ","\\par
",TReplaceFlags()<<rfReplaceAll)
does not replace any occurences in the AnsiString lots_of_rtf_text, but works
if I do it like this :-
int ii=lots_of_rtf_text.Pos("\\par \r\n\\par ");
while (ii>0)
{
lots_of_rtf_text.Delete(ii,12);
lots_of_rtf_text.Insert("\\par ",ii);
ii=lots_of_rtf_text.Pos("\\par \r\n\\par ");
}
Why does StringReplace fail in this case?
2) StringReplace(text_with_4500_lines,"\n","",TReplaceFlags()<<rfReplaceAll)
takes an incredibly long time to return - much much longer than to read those
lines in from the file. Why?
--
Mark Jacobs
DK Computing
www.dkcomputing.co.uk
 
 

Re:StringReplace Oddities

You should use mystring = StringReplace(mystring, ......
HTH Pete
"Mark Jacobs"
<www.jacobsm.com/mjmsg?Borland%20Newsgroup>wrote in
message news:44f707fa$ XXXX@XXXXX.COM ...
Quote
1) StringReplace(lots_of_rtf_text,"\\par \r\n\\par
","\\par ",TReplaceFlags()<<rfReplaceAll)
does not replace any occurences in the AnsiString
lots_of_rtf_text, but works if I do it like this :-

int ii=lots_of_rtf_text.Pos("\\par \r\n\\par ");
while (ii>0)
{
lots_of_rtf_text.Delete(ii,12);
lots_of_rtf_text.Insert("\\par ",ii);
ii=lots_of_rtf_text.Pos("\\par \r\n\\par ");
}

Why does StringReplace fail in this case?

2)
StringReplace(text_with_4500_lines,"\n","",TReplaceFlags()<<rfReplaceAll)
takes an incredibly long time to return - much much longer
than to read those lines in from the file. Why?

--

Mark Jacobs
DK Computing
www.dkcomputing.co.uk

 

Re:StringReplace Oddities

Pete Fraser wrote:
Quote
You should use mystring = StringReplace(mystring, ......
I already do - it's just not shown in the examples. Try it for yourself :-
lots_of_rtf_text=StringReplace(lots_of_rtf_text,
"\\par \r\n\\par ","\\par ",
TReplaceFlags()<<rfReplaceAll);
--
Mark Jacobs
jacobsm.com
 

{smallsort}