Text between: Difference between revisions

(added MiniScript example)
Line 1,520:
brown
BarBaz</pre>
 
=={{header|Objeck}}==
{{trans|Java}}
<lang objeck>class TextBetween {
function : Main(args : String[]) ~ Nil {
if(args->Size() = 3) {
TextBetween(args[0], args[1], args[2])->PrintLine();
};
}
 
function : TextBetween(thisText : String, startString : String, endString : String) ~ String {
startIndex := 0;
endIndex := 0;
 
if (startString->Equals("start"))
{
startIndex := 0;
} else {
startIndex := thisText->Find(startString);
if (startIndex < 0)
{
return "";
} else {
startIndex := startIndex + startString->Size();
};
};
 
if (endString->Equals("end"))
{
endIndex := thisText->Size();
} else {
endIndex := thisText->Find(endString);
if (endIndex <= 0)
{
return "";
} else {
};
};
 
return thisText->SubString(startIndex, endIndex - startIndex);
}
}</lang>
 
=={{header|Perl}}==
760

edits