Xbasic

WordFromEnd Function

Syntax

Output_String as C = WordFromEnd(C Input_String,C separator[,N num_words])

Arguments

Input_StringCharacter

A character string.

separator

Optional. Default = space (" "). The character that delimits words. If the optional Word_Delimiter parameter is not specified, a word is any sequence of one or more characters separated either by a space or the start or end of the string. If Word_Delimiter is specified, then Alpha Anywhere returns the strings that are delimited by the Word_Delimiter character. If Word_Delimiter is null (e.g ""), then WORD() returns a null value. Contrast with WORD2() which treats a null word delimiter as being the same as the default delimiter (e.g. space " ").

num_words

Default = 1. Specifies the number of words in the Input_String to return.

Returns

Output_StringCharacter

The return value

Description

Returns specified number of word(s) from then end of a string.

Discussion

WordFromEnd() returns one or more words from the end of a string, specified by the num_words parameter and delimited by separator, from the supplied Input_String.

Example

? wordFromEnd("This is a test"," ", 2)
= "a test"

See Also