Text between: Difference between revisions

Content added Content deleted
(→‎{{header|Haskell}}: Tidying - used fromMaybe in lieu of case)
(added MiniScript example)
Line 1,497: Line 1,497:
>textBetween("FooBarBazFooBuxQuux", "Foo", "Foo");
>textBetween("FooBarBazFooBuxQuux", "Foo", "Foo");
"BarBaz"</pre>
"BarBaz"</pre>

=={{header|MiniScript}}==
<lang MiniScript>textBetween = function(s, startDelim, endDelim)
startPos = s.indexOf(startDelim) + startDelim.len
if startDelim == "start" then startPos = 0
endPos = s.indexOf(endDelim, startPos)
if endDelim == "end" then endDelim = null
return s[startPos:endPos]
end function

print textBetween("Hello Rosetto Code world", "Hello ", " world")
print textBetween("Hello Rosetto Code world", "start", " world")
print textBetween("Hello Rosetto Code world", "Hello ", "end")
print textBetween("The quick brown fox jumps over the lazy other fox", "quick ", " fox")
print textBetween("FooBarBazFooBuxQuux", "Foo", "Foo")</lang>

{{out}}

<pre>Rosetto Code
Hello Rosetto Code
Rosetto Code world
brown
BarBaz</pre>


=={{header|Perl}}==
=={{header|Perl}}==