oxxxis Posted July 6, 2010 Report Share Posted July 6, 2010 Sveiki, cenšos sākt pielietot regex, bet pēc ārzemju materiāliem skatoties kaut kas īsti nesanāk. Man vajadzētu dabūt tekstu piemēram no šādas rindiņas: <span class="style"><strong>Teksts</strong></span> Ja vēlos no tikai <strong> tagiem dabūt tekstu ārā (starp šiem tagiem var būt jebkāds teksts), to varu izdarīt, bet līdz ko sarežģījās meklēšanas nosacījumi, nekas netiek atrasts. Ar šādu /<strong>(.*?)<\/strong>/ tiek atlasīts. Paldies jau iepriekš Quote Link to comment Share on other sites More sharing options...
mefisto Posted July 6, 2010 Report Share Posted July 6, 2010 /<strong>(.*)<\/strong>/ Quote Link to comment Share on other sites More sharing options...
oxxxis Posted July 6, 2010 Author Report Share Posted July 6, 2010 Bet kā atlasīt tekstu no šī? <span class="style"><strong>Teksts</strong></span> Quote Link to comment Share on other sites More sharing options...
daGrevis Posted July 7, 2010 Report Share Posted July 7, 2010 http://net.tutsplus.com/tutorials/php/advanced-regular-expression-tips-and-techniques/ Quote Link to comment Share on other sites More sharing options...
marcis Posted July 7, 2010 Report Share Posted July 7, 2010 Paskaidro detalizētāk savu problēmu, citādi mums viss strādā un saprotam tevi :) $matches = array(); preg_match('/<strong>(.*)<\/strong>/', '<span class="style"><strong>Teksts</strong></span>', $matches); print_r($matches); //output Array ( [0] => <strong>Teksts</strong> [1] => Teksts ) P.S. XML pārsēšanai izmantojam DOM vai SimpleXML, nevis regexp. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.