ako znie pls zapis pre regularny vyraz ktory vybere z retazca iba text medzi * a *?
Dakujem
Kód: Vybrať všetko
if (preg_match("/\*([^*]*)\*/", "aaaaa*bbb*cccc", $m) != 0) {
echo $m[1];
}
Kód: Vybrať všetko
echo preg_replace("/\*([^*]*)\*/", "<img src=\"$1\">", "aaa*obr1.gif*ccc*obr2.jpg*eee*obr3.png*ggg");Kód: Vybrať všetko
echo preg_replace("/\*([^\s*]*\.gif)\*/", "<img src=\"$1\">", "aaa* obr1.gif*ccc*obr2.jpg*eee*obr3.gif*ggg*obr4.gif *");Kód: Vybrať všetko
<?php
function find_txt($text)
{
$count = preg_match("/<!-- tlacenie start -->(.*)<!-- tlacenie end -->/U", $text, $matches);
return $count == 1 ? $matches[1] : "";
}
echo find_txt("<!-- tlacenie start --> aaa <!-- tlacenie end --> bbb <!-- tlacenie start --> ccc <!-- tlacenie end -->");
echo "<br><br>";
?>
Kód: Vybrať všetko
$text = "aa<!-- tlacenie start -->aa
sadfsdfsd
fd<!-- tlacenie end -->aa";Kód: Vybrať všetko
$count = preg_match("/<!-- tlacenie start -->(.*)<!-- tlacenie end -->/Us", $text, $matches);