HomeManualTopicsTypesSymbols
std_types::character/std::search
searches for the character from the start or the end of a string
Parameters
- self
- the character to search for
- stream
- the string to search in
- nth (default: 1)
- search for the nth occurrence; negative value search backwards
Results
- pos
- the position of the first occurrence of the character
- len
- 1 if successful
Description
If the character is not found, then pos and len are std::undefined.
Example
$str "abcdef"
search $pos $len 'd' str
dump! `pos `len
Output
pos: 4
len: 1
Example
$str "abcdef"
search $pos $len 'z' str
dump! `pos `len
Output
pos: <undefined>
len: <undefined>
Example
$str "In the wild, wild west we were alone."
search $pos $len 'w' str 2
dump! `pos `len
Output
pos: 14
len: 1
Example
$str "In the wild, wild west we were alone."
search $pos $len 'w' str -2
dump! `pos `len
Output
pos: 24
len: 1
Topic
Strings
Implements
std::search |
search from the grammar object from the start or end of the specified string |
See also
std::match |
match the grammar object with the start of the specified string |
std::match_back |
match the grammar object with the end of the specified string |