Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
30
Task/String-matching/Liberty-BASIC/string-matching.basic
Normal file
30
Task/String-matching/Liberty-BASIC/string-matching.basic
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
'1---Determining if the first string starts with second string
|
||||
st1$="first string"
|
||||
st2$="first"
|
||||
if left$(st1$,len(st2$))=st2$ then
|
||||
print "First string starts with second string."
|
||||
end if
|
||||
|
||||
'2---Determining if the first string contains the second string at any location
|
||||
'2.1---Print the location of the match for part 2
|
||||
st1$="Mississippi"
|
||||
st2$="i"
|
||||
if instr(st1$,st2$) then
|
||||
print "First string contains second string."
|
||||
print "Second string is at location ";instr(st1$,st2$)
|
||||
end if
|
||||
|
||||
'2.2---Handle multiple occurrences of a string for part 2.
|
||||
pos=instr(st1$,st2$)
|
||||
while pos
|
||||
count=count+1
|
||||
pos=instr(st1$,st2$,pos+len(st2$))
|
||||
wend
|
||||
print "Number of times second string appears in first string is ";count
|
||||
|
||||
'3---Determining if the first string ends with the second string
|
||||
st1$="first string"
|
||||
st2$="string"
|
||||
if right$(st1$,len(st2$))=st2$ then
|
||||
print "First string ends with second string."
|
||||
end if
|
||||
Loading…
Add table
Add a link
Reference in a new issue