Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Problem with StringReplace [solved]
Problem with StringReplace [solved] [message #7905] Wed, 31 January 2007 08:31 Go to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Hi all!

I was looking for a simple replace function - after a while of searching found such function in "TCore". But what I want to do doesnt work - maybe I do something wrong:

I have some Strings ...

Vector<String> Lines;

... and fill them ...

Lines = Split(LargeStringFromFile, ASeparator, false);

... and now I want to replace something in each line:

for (int i = 0; i < Lines.GetCount(); i++)
{
Lines.At(i) = StringReplace(Lines.At(i), "Something", "SomethingElse");
}

Lines.At(i) seems to do not contain what i expect. Some suggestions?


Thanks in advance,

WebChaot.

[Updated on: Wed, 31 January 2007 09:42] by Moderator

Report message to a moderator

Re: Problem with StringReplace [message #7906 is a reply to message #7905] Wed, 31 January 2007 08:43 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Forget it. It works as expected. The problem was, that I use some special characters as separator (" or ') - and dont mask them (\'). But I thought, that this is done automatically ( Format("%s", Separator) ) but isnt so.

But I let this thread here, because many users also look for StringReplace in past. Wink


WebChaot.
Re: Problem with StringReplace [message #7907 is a reply to message #7905] Wed, 31 January 2007 08:51 Go to previous messageGo to next message
WebChaot is currently offline  WebChaot
Messages: 53
Registered: September 2006
Location: Austria, Vienna
Member
Forget it again - all works as expected. It was a typically programmers mistake - using a variable before it was set Very Happy

So please delete this thread!

But paste somewhere in forum, where StringReplace can be found - would be useful for some others Wink

WebChaot.
Re: Problem with StringReplace [message #7908 is a reply to message #7907] Wed, 31 January 2007 09:43 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I would rather recommend

Lines[i] = StringReplace(Lines[i], "Something", "SomethingElse");

because .At is more complex method that extends container as needed (e.g. if you have 1 element in Lines and use Lines.At(10000), it adds 9999 empty Strings).

Mirek
Previous Topic: RegExp support
Next Topic: LOG files in ~/.App-name/logs/date.log in Linux
Goto Forum:
  


Current Time: Sat May 04 23:32:07 CEST 2024

Total time taken to generate the page: 0.03807 seconds