Dobrý den, potřebuju z php do delphi přepsat tuto funkci:
function cutter($left,$right, $str)
{
$str = substr(stristr($str, $left), strlen($left));
$leftLen = strlen(stristr($str, $right));
$leftLen = $leftLen ? -($leftLen) : strlen($str);
$code = substr($str, 0, $leftLen);
return $code;
}
Funkce vysekne z řetězce část, ohraničenou dvěma slovy. Věděl by někdo jak na to?
Fórum › Delphi
Delphi vyseknutí části textu mezi dvěma slovy

function cutter($left,$right, $str)
{
$str = substr(stristr($str, $left), strlen($left));
$leftLen = strlen(stristr($str, $right));
$leftLen = $leftLen ? -($leftLen) : strlen($str);
$code = substr($str, 0, $leftLen);
return $code;
}
// to nize aspiruje na copy-paste
// projevil jsem jistou snahu podle originalu nezasahovat do puvodnich retezcu
// I. - s null retezci, bliz PHPcku (pokud mas multibyte retezce pouzivej pred vetsinou klic. slov Ansi):
Function cutter(_left,_right,_str:pchar):pchar;
var i,j:pchar;left,right,str1:pchar;
a,b:integer;
Begin
left:=stralloc(4000); //widestring to nepotrebuje
right:=stralloc(4000);
str1:=stralloc(4000);
strcopy(left,_left);
strcopy(right,_right);
strcopy(str1,_str);
// v delphi neznam nesenzitivni porov.
strupper(left);
strupper(right);
strupper(str1);
i:=strpos(str1,left);
a:=0;
If i=nil then i:=str1 else a:=strlen(left);
j:=strpos(i,right);
If j<>nil then b:=strlen(j) else b:=0;
strlcopy(str1,_str+(i+a-str1),strlen(i)-b-a);
result:=str1;
strdispose(left);
strdispose(right);
End;
// neplnohodnotna ukazka pro string, nekomu muze vyhovovat
Function cutter2(left,right,str1:string):string;
var i:integer;
Begin
// v delphi neznam nesenzitivni porov.
for i:=1 to length(left) do left[i]:=upcase(left[i]);
for i:=1 to length(right) do right[i]:=upcase(right[i]);
for i:=1 to length(str1) do str1[i]:=upcase(str1[i]);
i:=pos(left,str1);
If i>0 then
str1:=copy(str1,i+length(left),length(str1)-(i));
i:=pos(right,str1);
If i>0 then
str1:=copy(str1,1,i-1);
result:=str1;
End;

Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 26 hostů
Podobná vlákna
Rozdíl mezi dvěma příkazy — založil Montezo
C# primka mezi dvema body — založil Kryspin
Komunikace mezi dvěma tlačítky — založil Barkas
Dny mezi dvema daty — založil kejta
Počty mezi dvěma selectory — založil adosl