Lasso Soft Inc. > Home

[ string->findlast ]

Method

[String->FindLast] returns the position of the last occurrence at which the first parameter is found within the string object, or 0 if the first parameter is not found within the string object. Requires a single string parameter. The pattern is not case sensitive. An optional -Case parameter compares the string taking case into account.

Optional offset and -length parameters allow a portion of the string object to be searched by specifying the offset at which to start searching and the number of characters from the offset to search, respectively. Offset defaults to the start of the search string. If omitted, -length defaults to searching to the end of the string.

Optional -patoffset and -patlength parameters allow only a portion of the pattern to be used as the search pattern by specifying the offset into the pattern and the number of characters from the pattern to search for, respectively. -Patoffset defaults to the start of the pattern. If omitted, -patlength defaults to searching for the entire pattern from the offset until the end.

  • Syntax
'String Object'->findlast('String Pattern')
'String Object'->findlast('String Pattern', -case)
'String Object'->findlast('String Pattern', integer, -length=integer)
'String Object'->findlast('String Pattern', integer, -length=integer, -patoffset=integer, -patlength=integer)
Examples
  • Beginner

This example performs a series of ->findLast operations on the sample string.

Code

local(str = 'As someone once said one day, "星星之火可以燎原"')

#str->findLast('once')
#str->findLast('once', 13)
#str->findLast('once', 1, -length=#str->size, -patOffset=1, -patLength=2)
#str->findLast('once', 1, -length=#str->size, -patOffset=2, -patLength=1)
#str->findLast('once', 1, -length=15, -patOffset=2, -patLength=1)
#str->findLast('once', 14, -length=8, -patOffset=2, -patLength=1)

Result

12
0
22
23
13
0

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2014 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft