hero Posted March 4, 2006 Share Posted March 4, 2006 hi all....i hope that someone will help me with this problem ..i have a string with some (tags) on it ..the tags are not html tags ...i used <:::test:::>...<:::/test:::> to easy point to the words i want later ...the problem is ..i would like to get the words between those tags ..i tried the preg_match_all but it seems to get the whole string not only the words between 2 tags ..an example about what i need :$stris="<:::test:::>hi my name is <:::/test:::><:::test:::> Testtext <:::/test:::> and here is another <:::test>text<:::/test:::>";the preg_match_all should return :1 match :hi my name is 2 match :Testtext3 match :text please help me to get the right expression,since it is not working with me ..here is what i have :[code]$findwords = preg_match_all("/<:::test:::>(.*)<:::\/test:::>/", $stris, $found);[/code] thanks in advance ... Quote Link to comment Share on other sites More sharing options...
wickning1 Posted March 5, 2006 Share Posted March 5, 2006 Use (.*?) instead of (.*). Other than that your regex is fine. Use something like this to get your values out:[code]<?phpforeach ($found as $match) { echo $match[1] . "<br>\n";}?>[/code] Quote Link to comment Share on other sites More sharing options...
hero Posted March 5, 2006 Author Share Posted March 5, 2006 [!--quoteo(post=351768:date=Mar 5 2006, 07:51 AM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Mar 5 2006, 07:51 AM) [snapback]351768[/snapback][/div][div class=\'quotemain\'][!--quotec--]Use (.*?) instead of (.*). Other than that your regex is fine. Use something like this to get your values out:[code]<?phpforeach ($found as $match) { echo $match[1] . "<br>\n";}?>[/code][/quote]hi ..thx for ur help ...it works now ..can you please tell me what did the ? changed !? thanks again .. 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.