String comparison: Difference between revisions

Content added Content deleted
m (Added Nimrod code)
Line 525: Line 525:
<lang nimrod>import strutils
<lang nimrod>import strutils


var s: string = "The quick brown fox"
var s1: string = "The quick brown"
if startsWith(s, "The quick"):
var s2: string = "The Quick Brown"
echo("Starts with: The quick")
echo("== : ", s1 == s2)
echo("!= : ", s1 != s2)
if endsWith(s, "brown Fox"):
echo("Ends with: brown fox")
echo("< : ", 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: " & $pos)</lang>
echo(">= : ", s1 >= s2)</lang>
{{out}}
{{out}}
<pre>Starts with: The quick
<pre>== : false
!= : true
Ends with: brown fox
< : false
" brown " is located at position: 9</pre>
<= : false
> : true
>= : true</pre>


=={{header|ooRexx}}==
=={{header|ooRexx}}==