RosettaCodeData/Task/String-matching/OxygenBasic/string-matching.oxy

36 lines
579 B
Plaintext

string s="sdfkjhgsdfkdfgkbopefioqwurti487sdfkrglkjfs9wrtgjglsdfkdkjcnmmb.,msfjflkjsdfk"
string f="sdfk"
string cr=chr(13)+chr(10),tab=chr(9)
string pr="FIND STRING LOCATIONS" cr cr
sys a=0, b=1, count=0, ls=len(s), lf=len(f)
do
a=instr b,s,f
if a=0 then exit do
count++
if a=1 then pr+="Begins with keyword" cr
pr+=count tab a cr
if a=ls-lf+1 then pr+="Ends with keyword at " a cr
b=a+1
end do
pr+=cr "Total matches: " count cr
print pr
'FIND STRING LOCATIONS
'
'Begins with keyword
'1 1
'2 8
'3 32
'4 51
'5 73
'Ends with keyword at 73
'
'Total matches: 5