SRL Archive - Help

Help with this trim problem :/


ilklhl1Lihl1

2012-06-03 14:00:59

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

2012-06-03 14:08:22

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

2012-06-03 14:39:06

Found the solution :)

Le Jingle

2012-06-03 14:50:27

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 ; )