Sign in Join
FPDoc Onlineexperiment

ExtractDelimited function

In unit StrUtils

Extract the N-th delimited part from a string.

Declaration

pascal
function ExtractDelimited(N: Integer; const S: string; 
 const Delims: TSysCharSet): string

Arguments

N

Which word to extract.

S

String to extract word from.

Delims

Characters to use as word delimiters.

Function result

N-th word.

Description

ExtractDelimited extracts the N-th part from the string S. The set of characters in Delims are used to mark part boundaries. When a delimiter is encountered, a new part is started and the old part is ended. Another way of stating this is that any (possibly empty) series of characters not in Delims, situated between 2 characters in Delims, it is considered as piece of a part. This means that if 2 delimiter characters appear next to each other, there is an empty part between it. If an N-th part cannot be found, an empty string is returned. However, unlike ExtractWord, an empty string is a valid return value, i.e. a part can be empty.

The predefined constant StdWordDelims can be used for the Delims argument. The predefined constant Brackets would be better suited the Delims argument e.g. in case factors in a mathematical expression are searched.

Errors

None.

See also

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.