String matching: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
|||
Line 3,595: | Line 3,595: | ||
{1,16,33} |
{1,16,33} |
||
</pre> |
</pre> |
||
=={{header|Phixmonti}}== |
|||
Simple solution |
|||
<syntaxhighlight lang="Phixmonti">/# Rosetta Code problem: https://rosettacode.org/wiki/String_prepend |
|||
by Galileo, 11/2022 #/ |
|||
include ..\Utilitys.pmt |
|||
"the last thing the man said was the" "the" pstack |
|||
len var l >ps |
|||
1 l slice tps == if "Begins with keyword" ? endif |
|||
0 l - l slice tps == if "Ends with keyword" ? endif |
|||
tail ps> find dup if "Keyword appears first at " print 1 + print " position" ? else drop endif |
|||
drop |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
["the last thing the man said was the", "the"] |
|||
Begins with keyword |
|||
Ends with keyword |
|||
Keyword appears first at 16 position |
|||
=== Press any key to exit ===</pre> |
|||
More complex solution |
|||
<syntaxhighlight lang="Phixmonti">/# Rosetta Code problem: https://rosettacode.org/wiki/String_prepend |
|||
by Galileo, 11/2022 #/ |
|||
include ..\Utilitys.pmt |
|||
"the last thing the man said was the" "the" pstack |
|||
( ) rot rot >ps |
|||
true while |
|||
tps find dup >ps |
|||
if swap tps 0 put swap 32 ps> set true else ps> endif |
|||
endwhile |
|||
len ps> len nip - 1 + >ps drop |
|||
len for get |
|||
dup 1 == if "Begins with keyword" ? drop else |
|||
dup tps == if "Ends with keyword" ? drop else |
|||
"Locate at position " print ? |
|||
endif endif |
|||
endfor |
|||
ps> drop |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
["the last thing the man said was the", "the"] |
|||
Begins with keyword |
|||
Locate at position 16 |
|||
Ends with keyword |
|||
=== Press any key to exit ===</pre> |
|||
=={{header|PHP}}== |
=={{header|PHP}}== |