Scan string

Purpose: Scans string for another string or a character.

scan-string <string> [ start-with <start with> ] [ length <length> ] \
    for <for string> \
    status <status>

scan-string will search <string> for <for string> (which can be a string or character such as 'A' for instance) specified in "for" clause.

If "start-with" clause is used, then the first byte to start the scan from is <start with>; with the very first byte being specified as 0.

If "length" clause is used, then only the <length> bytes are scanned, starting either from the beginning of <string> or from byte <start with> if "start-with" clause is specified.

<status> in "status" clause will be the byte position from the beginning of <string> where <for string> is found, or GG_ERR_POSITION if <for string> is not found.
Examples
Getting the byte position of a string:
set-string s = "wow this is a string!"
scan-string s start-with 3 length 13 for "this" status pos
if-true pos equal 4
    @Found string where it should be!
end-if

Getting the byte position of a character:
set-string s = "wow this is a string!"
scan-string s for 'g' status pos
if-true pos equal 19
    @Found character where it should be!
end-if

See also
Strings
copy-string  
count-substring  
delete-string  
double-string  
lower-string  
match-regex  
new-string  
number-string  
read-split  
replace-string  
scan-string  
set-string  
split-string  
string-double  
string-expressions  
string-length  
string-number  
trim-string  
upper-string  
write-string  
See all
documentation


Copyright (c) 2019-2025 Gliim LLC. All contents on this web site is "AS IS" without warranties or guarantees of any kind.