嗨,我需要以下 php 函数的 android 函数
function BetweenStr($InputString, $StartStr, $EndStr, $StartLoc=0) {
if (($StartLoc = strpos($InputString, $StartStr, $StartLoc)) === false) {
return;
}
$StartLoc += strlen($StartStr);
if (!$EndStr) {
$EndStr = $StartStr;
}
if (!$EndLoc = strpos($InputString, $EndStr, $StartLoc)) {
return;
}
return substr($InputString, $StartLoc, ($EndLoc-$StartLoc));
}
echo BetweenStr("Cut1 this will be output cut2", 'cut1', 'cut2', 0)
Result will be :"this will be output
这就是我所做的。但它仍然有问题
data="Cut1 this will be output cut2";
String substr=data.subString(data.indexOf("cut1"),data.indexOf("cut2"));