Sign in Join
FPDoc Onlineexperiment

WordPosition function

In unit StrUtils

Search position of Nth word in a string.

Declaration

pascal
function WordPosition(const N: Integer; const S: string; 
 const WordDelims: TSysCharSet): SizeInt

Arguments

N

Which word to search for.

S

String to search in.

WordDelims

Characters to be used as word delimiters.

Function result

Position of the N-th word, or -1 if there is none.

Description

WordPosition returns the position (in characters) of the N-th word in the string S. A word is a non-empty string of characters bounded by one of the characters in WordDelims. If N is out of range, zero is returned.

The predefined StdWordDelims constant can be used for the WordDelims argument.

Errors

None

See also

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