[Overview][Resource strings][Constants][Types][Procedures and functions][Index] | Reference for unit 'strutils' (#rtl)

# ExtractSubstr

Extract a word from a string, starting at a given position in the string.

## Declaration

Source position: strutils.pp line 158

`function ExtractSubstr(`
`const S: String;`
`var Pos: Integer;`
`const Delims: TSysCharSet`
`):String;`

## Arguments

`S` |  | String to search in.
`Pos` |  | Initial position to start extracting. On exit returns the position of the next word.
`Delims` |  | Characters to use as word delimiters

## Function result

The extracted word.

## Description

ExtractSubStr returns all characters from S starting at position Pos till the first character in Delims, or till the end of S is reached. The delimiter character is not included in the result. Pos is then updated to point to the next first non-delimiter character in S. If Pos is larger than the Length of S, an empty string is returned.

The pre-defined constant StdWordDelims can be used for the Delims argument.

## Errors

None.

## See also

ExtractDelimited |  | Extract the N-th delimited part from a string.
ExtractWord |  | Extract the N-th word out of a string.
ExtractWordPos |  | Extract a word from a string, and return the position where it was located in the string.

The latest version of this document can be found at lazarus-ccr.sourceforge.net.