| View previous topic :: View next topic |
| Author |
Message |
delphi7man Member
Joined: 02 Oct 2003 Posts: 1
|
Posted: 02/10/03 20:33 Post subject: String Manipulation via Delimiter: Help |
|
|
Hello all,
Let me introduce my self real fast before I ask my question. I am 20 years old and my name is Jeff. I have been programming in delphi for about a year now and I am now stuck on something I cannot figure out, but the issue may be very simple.
Issue:
I want to extact a portion of text from the end of a string via delimiter(s)
for example "sData:='abunchoftextthatidontwant!@ I want this information'"
I want to take out the part of the string that says "I want this text" via the delimiter "!@". Do any of you know of a way to do this.
Just to give you the idea of the whole picture is that Im trying to create and IRC bot. Thanks much to everybody in advance! |
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 206
|
Posted: 03/10/03 16:25 Post subject: |
|
|
Hi Jeff,
The following function returns the text after the delimiter.
| Code: | function GetTail(const sData: String): String;
const
Delimiter = '!@';
var
DelimiterPos: Integer;
begin
DelimiterPos := Pos(Delimiter, sData);
if DelimiterPos > 0 then
Result := Copy(sData,
DelimiterPos + Length(Delimiter),
Length(sData) - (DelimiterPos - Length(Delimiter)) + 1)
else // No delimiter
Result := '';
end; |
Hope that it helps.
Cheers,
Kambiz |
|
| Back to top |
|
 |
|