[−][src]Function phpify::string::strpos
pub fn strpos<H, N>(haystack: H, needle: N, offset: isize) -> Option<usize> where
H: AsRef<str>,
N: AsRef<str>,
Find the position of the first occurrence of a substring in a string.
Description
Find the numeric position of the first occurrence of needle in the haystack string.
Parameters
offset
If the offset is negative, the search will start this number of characters counted from the end of the string.
Examples
Example #1 strpos() example
use phpify::string::strpos; let mystring = "abc"; let findme = "a"; let pos = strpos(mystring, findme, 0).unwrap(); assert_eq!(pos, 0);
Example #2 using an offset
use phpify::string::strpos; let newstring = "abcdef abcdef"; let pos = strpos(newstring, "a", 1).unwrap(); assert_eq!(pos, 7);