Word()

Summary

Extracts one word from a string.

Changes

Added negative position and optional delimiter in Version 6.0/2012.

Syntax

w = Word(string str, integer pos, optional string delim)

Argument Contents
str Any string
pos The position of the word to be returned; negative value searches from the end
delim An optional string of delimiter characters

Returns

A string that is a substring of str that corresponds to the specified word.

Notes

  • If pos is negative then the words are counted from the end of the string.

  • Words are separated by spaces, tabs, and punctuation marks, and optionally any characters in delim.

Example

Word("the quick brown fox", 2) // returns "quick"
Word("the quick brown fox", 5) // returns null
Word("the quick brown fox", 1) // returns "the"
Word("the quick brown fox", -1) // returns "fox"
Word("the#quick#brown#fox", -2, "#") // returns "brown"

See Also

Function Summary
CompareStrings() Compares two strings to see if they match
JoinStrings() Returns a concatenated string separated by the delimiter
SplitString() Divides a string into pieces separated by vertical bars (|)
ParseString() Divides a string into pieces separated by the specified delimiters
Substring() Extracts a portion of a string