String matching: Difference between revisions

No edit summary
Line 2,383:
</lang>
 
=={{header|MiniScript}}==
<lang MiniScript>first = "The brown dog jumped jumped and jumped"
second = "jumped"
 
location = first.indexOf(second)
lastLocation = location
 
print "Does """ + first + """ start with """ + second + """?"
if location == 0 then print "Yes" else print "No"
 
print "Does """ + first + """ contain """ + second + """?"
if location == null then
print "No"
else
print "Yes"
print "Match position = " + first.indexOf(second)
end if
 
print "Does """ + first + """ contain multiple references to """ + second + """?"
if location == null then
print "No"
else
start = first.indexOf(second, location)
if start == null then print "No"
while start != null
lastLocation = start
print "Match at location " + start
start = first.indexOf(second, start)
end while
end if
 
print "Does """ + first + """ end with """ + second + """?"
if lastLocation == first.len - second.len then print "Yes" else print "no"
</lang>
{{out}}
<pre>
 
Does "The brown dog jumped jumped and jumped" start with "jumped"?
No
Does "The brown dog jumped jumped and jumped" contain "jumped"?
Yes
Match position = 14
Does "The brown dog jumped jumped and jumped" contain multiple references to "jumped"?
Match at location 21
Match at location 32
Does "The brown dog jumped jumped and jumped" end with "jumped"?
Yes
</pre>
 
=={{header|NetRexx}}==