vl-string-position
 
 
 

Looks for a character with the specified ASCII code in a string

(vl-string-position char-codestr [start-pos [from-end-p]])

Arguments

char-code

The integer representation of the character to be searched.

str

The string to be searched.

start-pos

The position to begin searching from in the string (first character is 0); 0 if omitted.

from-end-p

If T is specified for this argument, the search begins at the end of the string and continues backward to pos.

Return Values

An integer representing the displacement at which char-code was found from the beginning of the string; nil if the character was not found.

Examples

_$ (vl-string-position (ascii
"z") "azbdc")
1
_$ (vl-string-position 122
"azbzc")
1
_$ (vl-string-position (ascii
"x") "azbzc")
nil

The search string used in the following example contains two “z” characters. Reading from left to right, with the first character being displacement 0, there is one z at displacement 1 and another z at displacement 3:

_$ (vl-string-position (ascii
"z") "azbzlmnqc")
1

Searching from left to right (the default), the “z” in position 1 is the first one vl-string-position encounters. But when searching from right to left, as in the following example, the “z” in position 3 is the first one encountered:

_$ (vl-string-position (ascii
"z") "azbzlmnqc" nil t)
3