FUNCTION::STRPOS(3stap)

πŸ’– FUNCTION::STRPOS πŸ’–

okay bestie, so this little cutie lives in the A collection of standard strin manual, and it's literally the page you want when you're out here hunting for one string inside another. it's giving detective energy πŸ”βœ¨


✨ NAME ✨

function::strpos</purl> β€” returns location of a substring within another string πŸŽ€


🌸 SYNOPSIS 🌸

strpos:long(s1:string,s2:string)

like, that's the whole vibe. two strings go in, a long comes out. slay. πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • s1 β€” the string to search in. this is your main character, the place where the searching happens 🌈
  • s2 β€” the substring to find. this is the little one you're looking for, the "where are you bestie" of it all πŸ₯Ί

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea, fr fr. this function returns the location of the first occurence of string s2 within s1.

and the way that works is: the return value is 0 in case s2 is a prefix of s1. so if your substring is sitting right at the very front like it owns the place? boom, zero. iconic.

but if s2 is not a substring of s1 at all β€” like, she's just not there, no cap β€” then the return value is -1. πŸ’€

so yeah, no cap, those are the two special cases you gotta keep in your head: 0 for "she's at the front" and -1 for "she's not here". periodt. πŸ’–


🌟 SEE ALSO 🌟

  • tapset::string(3stap) β€” go read this one too bestie, it's the whole string tapset and it's lowkey essential 🫢

anyway that's the page!! this came to you from the SystemTap Tapset Reference, version Ver, dated September 2026 πŸŽ€ thanks for reading, mwah, go grep something and stay hydrated πŸ’–βœ¨πŸ¦‹πŸ’…

πŸ“¦ where this page comes from