idkfa Posted February 7, 2005 Report Share Posted February 7, 2005 Kā pārbaudīt, vai, piemēram $mainīgais1, sastāv tikai no mazajiem burtiem + speciaalie simboli - un _ Link to comment Share on other sites More sharing options...
Venom Posted February 8, 2005 Report Share Posted February 8, 2005 preg_match('#[\_\-a-z]+#',$mainigais) Link to comment Share on other sites More sharing options...
idkfa Posted February 8, 2005 Author Report Share Posted February 8, 2005 viss ir ok, paldies, bet veel vajadzeetu lai atstarpes neljau. Link to comment Share on other sites More sharing options...
рпр Posted February 8, 2005 Report Share Posted February 8, 2005 preg_match('#^[\_\-a-z]+$#',$mainigais) Link to comment Share on other sites More sharing options...
idkfa Posted February 9, 2005 Author Report Share Posted February 9, 2005 Vienalga nesaprotu tos preg_blahblahblah Problēma sekojoša, ir kautkāds mainīgais $lala = "<tb class="lala"> blablabla </td>"; Kā var dabūt mainīgajā $lala tikai to, kas ir starp tiem tagiem? Link to comment Share on other sites More sharing options...
Venom Posted February 10, 2005 Report Share Posted February 10, 2005 nu, ja nepatīk regexpi, tad pēc piemēra varētu iztikt ar $lala=substr($txt,$tmp=strpos($txt,'>')+1,strlen($txt)- --$tmp+strpos($txt,'<',1)); Link to comment Share on other sites More sharing options...
idkfa Posted February 10, 2005 Author Report Share Posted February 10, 2005 nu, ja nepatīk regexpi, tad pēc piemēra varētu iztikt ar$lala=substr($txt,$tmp=strpos($txt,'>')+1,strlen($txt)- --$tmp+strpos($txt,'<',1)); 13589[/snapback] Bet problēma ir tāda, ka man vajag to $lala palabot, un pēctam ielikt atpakaļ tur kur bija. Link to comment Share on other sites More sharing options...
Venom Posted February 10, 2005 Report Share Posted February 10, 2005 tad labāk izmantot kaučko tādu: $txt='<b> any text here </b>'; function cb($match) { //print '<pre>'.print_r($match,1).'</pre>'; return $match[1].str_replace(' text','thing',trim($match[2])); } echo preg_replace_callback('#(<[a-z]+[^>]*>)([^<]+)#','cb',$txt); Link to comment Share on other sites More sharing options...
Recommended Posts