954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to split a string?

how would i go about spliting a string that is stored in a StringList ?

information in string looks like this:

Name
RanK

now i need to split them so i can use a funcation like this

data[0] for Name
and
data[1] for rank

can sumone help me please?
thanks

Simon180
Light Poster
29 posts since Feb 2010
Reputation Points: 10
Solved Threads: 0
 

information in string looks like this:

Name RanK

From this, I understand that the string looks like NameRank (Name#D#ARank). If you want to split it, use Pos and copy functions.

iPos := Pos('#13#10', yourString). 
Name := copy(yourString, 1, iPos-1);
Delete(yourString, 1, iPos + 1); //delete <CR><LF>
//now, yourString stores only the rank


If my supposition is wrong, post your code.

Cheers,
Ionut

Ionelul
Junior Poster in Training
94 posts since Dec 2009
Reputation Points: 17
Solved Threads: 27
 

how would i go about spliting a string that is stored in a StringList ?

information in string looks like this:

Name RanK

now i need to split them so i can use a funcation like this

data[0] for Name and data[1] for rank

can sumone help me please? thanks

Delphi-TStringList

FlamingClaw
Posting Pro
559 posts since Feb 2009
Reputation Points: 132
Solved Threads: 138
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You