String matching: Difference between revisions

no edit summary
No edit summary
Line 3,811:
loc = "abab".find("ab",loc+1) #returns 2</lang>
 
=={{header|QB64}}==
<lang QB64>
DefStr S
DefInt P
string2 = "dogs"
string1 = "dogs and cats are often enemies,because dogs are stronger than cats, but cats sometimes can be friend to dogs"
position = 0
pcount = 0
Print "Searching "; string2; " into "; string1
While (InStr(position, string1, string2) > 0)
position = InStr(position + 1, string1, string2)
pcount = pcount + 1
If position = 1 Then Print string1; "- starts with -"; string2
Print position
If position = Len(string1) - Len(string2) + 1 Then
Print string1; "- ends with -"; string2
Exit While
End If
Wend
Print string2; " is present "; pcount; " times into "; string1
</lang>
=={{header|Quackery}}==