[fpc-pascal] Easy string-splitting

S. Fisher expandafter at yahoo.com
Sun Mar 24 11:58:17 CET 2013


uses regexpr, classes;

var
  pieces : tstringlist;
  s : string;
begin
  pieces := TStringList.create;
  SplitRegExpr( '--+| *, *',
                'thus--and even , hurly-burly,willy-nilly',
                pieces );
  for s in pieces do  writeln( s, '<');
  pieces.destroy;
end.

Output:

thus<
and even<
hurly-burly<
willy-nilly<




More information about the fpc-pascal mailing list