UserLand Software Home  |  Manila  |  Radio  |  Support  |  News

DocServer

Prev | Next | String Verbs > string.firstWord

string.firstWord

Syntax string.firstWord (string)

Params string is the string from which you wish to extract the first word.

Action Extracts the first word from string. A word is defined as a string of characters terminated by the character currently defined as the wordChar.

Returns The resulting string.

Examples string.firstWord ("Eat a good lunch!")

   » "Eat"

string.firstWord ("Coming-into-being is here.")

   » "Coming-into-being"

This return value assumes a space is still the wordChar.

string.setWordChar ("-")
string.firstWord ("Coming-into-being just left.")

   » "Coming" // assuming hyphen is now wordChar

The first hyphen occurs after the word "coming." This example sets hyphen as the wordChar.

string.setWordChar (' ');
s = "Eat a good lunch!";
string.firstWord (s) + " " + string.lastWord (s)

   » "Eat lunch!"

The string returned by this verb does not include the word delimiter.
Space is necessary in above script because string.firstWord does not include the delimiter in the word it extracts.

See Also string.getWordChar

string.lastWord

string.setWordChar

Prev | Next | String Verbs > string.firstWord

Anonymization by Anonymouse.org ~ Adverts
Anonymouse better ad-free, faster and with encryption?
X