Log in

View Full Version : Help with this trim problem :/



ilklhl1Lihl1
06-03-2012, 06:00 PM
I am trying to trim a string from the fourth char to the end -1

here is my function:

function trim2(str: string): string;
var
i, l: Integer;
begin
l := Length(str);
for i := 4 to l-1 do
Result := Copy(str, i, ((l + 1) - i));
end;

It returns nothing, can somebody help me with this?

My string ressembles to something like this '[ ] blablabla?' so i want to remove the '[ ] ' and the '?'

Thank you :)

Le Jingle
06-03-2012, 06:08 PM
Again, please refer to here, http://villavu.com/forum/showthread.php?t=82205

I believe it's the Allbetween func you are describing. It really is a useful string handling command thread ^.^

ilklhl1Lihl1
06-03-2012, 06:39 PM
Found the solution :)

Le Jingle
06-03-2012, 06:50 PM
Oh, I didn't notice your question mark in the OP;
You could incorporate the After func to trim off the question mark;
I'm unsure if there's a better way around it (which I'm sure there is), however I'm a learner too. Just trying to help you think about it though! (and me too)

E: Looks like you got it ; )