
$test = array('clanky/strana-([0-9]*)' = >'modules.php?name=K88_News&pagenum=$1')



function preg_replace_with_braces($Regexp,$Remplacement,$Texte)
{
preg_match_all($Regexp,$Texte,$Resultats,PREG_SET_ORDER);

$SVGRemplacement=$Remplacement;
foreach($Resultats as $Resultat)
{//For each result
$Remplacement=$SVGRemplacement;
foreach($Resultat as $n=>$Match)
{//For each set of capturing parenthesis
if($n>0 && strpos($Match,'{')!==false)
{//We find a open brace in our regexp : we'll need to find the closing one !
$InitialMatch=$Match;
$Offset=strpos($Texte,$Resultat[0]);
$Offset=strpos($Texte,$Match,$Offset);//We move the caret to the good place : let's start !
$Depart=$Offset;
$Taille=strlen($Texte);
$NestingLevel=0;
while($NestingLevel>=0 && $Offset<$Taille)
{//Browse the string, searching for braces. Perhaps the most important place !
$Offset++;
if($Texte[$Offset]=='{')
$NestingLevel++;
elseif($Texte[$Offset]=='}')
$NestingLevel--;
}
$Match=substr($Texte,$Depart,$Offset-$Depart);
$Resultat[0]=str_replace($InitialMatch,$Match,$Resultat[0]);
}
$Remplacement=str_replace('$' . $n,$Match,$Remplacement);
}
$Texte=str_replace($Resultat[0],$Remplacement,$Texte);
}
return $Texte;
}

<a href='blabla'>blabla</a>
aby bolo
<a href="blabla">blabla</a>


a = 'modules.php?name=Statistics&op=DailyStats&year=$1&month=$2&date=$3'
$match_count = substr_count(a, '$');
$match_count = $match_count + 1;
for ($i = 1; $i < $match_count; $i++) {
$a = str_replace('$'.$i, '([0-9]*)', $a);
}


preg_replace("/\\$[0-9]+/", "([0-9]*)", $str);

preg_replace("/\\$pa_z0_9_[0-9]+/", "([a-z0-9\-]*)", $vyraz);


preg_replace("/\\$pa_z0_9_(*)+/", "([a-z0-9\-]*)", $vyraz);

Obsah fóra BLASSENweb » Rady a porady - ostatní
|
|