Jump to content

String comparison: Difference between revisions

m
m (Added Nimrod code)
Line 525:
<lang nimrod>import strutils
 
var ss1: string = "The quick brown fox"
ifvar startsWith(s,s2: string = "The quickQuick Brown"):
echo("Starts== with: The", quick"s1 == s2)
echo("!= : ", s1 != s2)
if endsWith(s, "brown Fox"):
echo("Ends< with: brown", fox"s1 < s2)
echo("<= : ", s1 <= s2)
var pos = find(s, " brown ") # -1 if not found
echo("> : ", s1 > s2)
if contains(s, " brown "): # showing the contains() proc, but could use if pos!=-1:
echo('"'>= &: ", brown " & '"' & " is located at position: "s1 &>= $poss2)</lang>
{{out}}
<pre>Starts== with: The quickfalse
!= : true
Ends with: brown fox
< : false
" brown " is located at position: 9</pre>
<= : false
> : true
>= : true</pre>
 
=={{header|ooRexx}}==
118

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.