RE: Parse
Todd Fiske <[email protected]> Sat, 16 Aug 2003 18:33:43 -0400
| Newsgroups | gmane.comp.lang.delphi.programming |
|---|---|
| Organization | Tiny Piles of Chaos |
| Message-ID | <[email protected]> |
A variation, extract as Glenn did or with the Jedi function, then use
CommaText to split up the results:
var
S,N: string;
P: integer;
sl : TStringList;
...
S:='Values are (10,123,0)';
{Extract the numbers}
P:=pos('(',S);
Delete(S,1,P);
P:=pos(')',S);
Delete(S,P,Length(S));
sl := TStringList.Create;
sl.CommaText := s;
// sl[0] = '10'
// sl[1] = '123'
// sl[2] = '0'
// sl.Count = 3
CommaText will split on commas and spaces by default, which makes it a
quick way to split a string into its parts. As of D6 you can specify a
separator character.
- Todd
------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
Printer at Myinks.com. Free s/h on orders $50 or more to the US & Canada. http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/i7folB/TM
---------------------------------------------------------------------~->
Delphi VCL Top Sites!
http://www.sandbrooksoftware.com/TS/TS2/Components.shtml
---------------------------------------------------------------
Unsubscribe:[email protected]
List owner:[email protected]
---------------------------------------------------------------
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/