DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

String Manipulation via Delimiter: Help

 
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming
View previous topic :: View next topic  
Author Message
delphi7man
Member


Joined: 02 Oct 2003
Posts: 1

PostPosted: 02/10/03 20:33    Post subject: String Manipulation via Delimiter: Help Reply with quote

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
View user's profile
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 206

PostPosted: 03/10/03 16:25    Post subject: Reply with quote

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
View user's profile Send e-mail Visit poster's website
Display posts from previous:   
   Reply to topic    DELPHI AREA Forum Index -> Delphi Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB 2.0.6 © 2001, 2002 phpBB Group