String matching: Difference between revisions

Content added Content deleted
(easylang)
Line 1,710: Line 1,710:
(string-index "net" "Antoinette") → 5 ;; substring location
(string-index "net" "Antoinette") → 5 ;; substring location
</syntaxhighlight>
</syntaxhighlight>

=={{header|EasyLang}}==

<syntaxhighlight lang=easylang>
func starts s$ t$ .
if substr s$ 1 len t$ = t$
return 1
.
return 0
.
func ends s$ t$ .
if substr s$ (len s$ - len t$ + 1) len t$ = t$
return 1
.
return 0
.
func contains s$ t$ .
for i to len s$ - len t$ + 1
if substr s$ i len t$ = t$
return 1
.
.
return 0
.
print starts "hello world" "he"
print ends "hello world" "rld"
print contains "hello world" "wo"
</syntaxhighlight>



=={{header|Elena}}==
=={{header|Elena}}==