Here is a Delphi implementation of the common PHP function 'explode'.

http://www.michael-puff.de/Developer/Delphi/Code-Snippets/Explode.html

Your example then becomes to
..
A := Explode('-', 'ab-cd-ef');
writeln(A[1]); // expect 'cd'
..

The inverse is accomplished by using PHP like 'implode', which glues all 
splitted parts back to a single string.

Wolfram



> -----Ursprüngliche Nachricht-----
> Von: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
> Gesendet: 10.07.07 13:04:31
> An: FPC-Pascal users discussions <fpc-pascal@lists.freepascal.org>
> Betreff: [fpc-pascal] splitting string into array


> 
> Hi,
> 
> is there any function in the libraries of fpc for splitting a string
> into an array naming the separator?
> 
> In awk for eample if you do this:
> 
>       split("ab-cd-ef", x, "-")
>       print x[2]
> 
> it would split up the first string using "-" as separator and print
> 
>       cd
> 
> to the output. That's what I'm searching for.
> In pascal. ;)
> 
> TIA,
> Marc
> 
> 
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to