String.LastField

From Xojo Documentation

Method

LastField()

New in 2019r2

Supported for all project types and targets.

Returns the last field from a string of data. The first field is numbered 1. If you need to parse binary data, use a MemoryBlock instead.

Syntax

result=stringVariable.LastField(separator)

Part Type Description
result String The field value desired.
stringVariable String The string that contains the desired field, with the field separated by the Separator string.
separator String The string that delimits the fields of data.

Notes

The LastField function returns the last field value from the source based upon the separator passed.

The separator may be a string of any length.

Examples

This example returns "Male"

Var s, field As String
s = "Dan*Smith*11/22/69*5125554323*Male"
field = s.LastField("*")
MessageBox(field)

This example demonstrates the use of a multiple character separator.

Var days As String = "Monday--Tuesday--Wednesday--Thursday--Friday--Saturday--Sunday"
Var theDay As String = days.LastField("--") // sets theDay to "Sunday"

See Also

String.CountFields, String.NthField, Split functions.