chickadee » srfi-207 » bytestring-contains

(bytestring-contains bytevector₁ bytevector₂ [start₁ end₁ start₂ end₂])procedure
(bytestring-contains-right bytevector₁ bytevector₂ [start₁ end₁ start₂ end₂])procedure

Does the subvector of bytevector₁ specified by start₁ and end₁ contain the sequence of bytes given by the subvector of bytevector₂ specified by start₂ and end₂?

Returns #f if there is no match. If start₂ = end₂, bytestring-contains returns start₁ but bytestring-contains-right returns end₁. Otherwise returns the index in bytevector₁ for the first character of the first/last match; that index lies within the half-open interval [start₁, end₁), and the match lies entirely within the [start₁, end₁) range of bytevector₁.

(Extension based on string-contains, etc. from srfi-152.)

(bytestring-contains #u8(1 2 3 4 5) #u8(2 3)) ⇒ 1
(bytestring-contains #u8"hitchhiker" #u8"tchh" 2 7) ⇒ 2
(bytestring-contains #u8"hitchhiker" #u8"hacker" 0 10 2) ⇒ #f
(bytestring-contains-right #u8"banana" #u8"an") ⇒ 3