File: string-last-position

package info (click to toggle)
scheme9 2025.08.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: lisp: 16,752; ansic: 11,869; sh: 806; makefile: 237; sed: 6
file content (27 lines) | stat: -rw-r--r-- 1,252 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
S9 LIB  (string-last-position string1 string2)          ==>  integer | #f
        (string-ci-last-position string1 string2)       ==>  integer | #f
        (string-last-word-position string1 string2)     ==>  integer | #f
        (string-ci-last-word-position string1 string2)  ==>  integer | #f

        (load-from-library "string-last-position.scm")

Find the last occurrence of a small string STRING1 in a large
string STRING2. Return the position of the rightmost substring of
STRING2 beginning with STRING1. When STRING2 does not contain
STRING1, return #F. STRING-CI-LAST-POSITION performs the same
function, but ignores case.

STRING-LAST-WORD-POSITION (STRING-CI-LAST-WORD-POSITION) differs from
STRING-LAST-POSITION (STRING-CI-LAST-POSITION) in that is matches only
full words, where a full word is a subsequence of characters that
is delimited on both sides by one of the following:

        - the beginning of the string;
        - the end of the string;
        - a non-alphabetic character.

(string-last-position "a" "aaaaa")        ==>  4
(string-ci-last-position "A" "ab ac")     ==>  3
(string-last-position "ax" "ab ac")       ==>  #f
(string-last-word-position "a" "ab a c")  ==>  3
(string-last-word-position "a" "ab ac")   ==>  #f