Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 deletions
30
Task/String-matching/Liberty-BASIC/string-matching.liberty
Normal file
30
Task/String-matching/Liberty-BASIC/string-matching.liberty
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