play_ Posted August 27, 2009 Share Posted August 27, 2009 Okay. This may be hard to explain, expecially at 7am with no sleep. I have a comments section on this site, where users can quote other users. i'm using bbcode for this, so something would ideally be replaced with <blockquote>username said: something </blockquote> What I have now is this [/code] $str = " "; $m = preg_replace("/\ [^\]]{1' date='}\']/", "<blockquote>", $str); [/code] This returns $m as into <blockquote>. Question: How can i extract username (in this case, play) out of that string? if it possible to insert the match into the replacement? example: $m = preg_match("/\ [^\]]{1' date='}\']/", "<blockquote>insert 'play' here", $str); Quote Link to comment https://forums.phpfreaks.com/topic/172110-solved-extracting-word-out-of-a-string/ Share on other sites More sharing options...
ignace Posted August 27, 2009 Share Posted August 27, 2009 Save yourself the trouble and use: http://us3.php.net/manual/en/book.bbcode.php Quote Link to comment https://forums.phpfreaks.com/topic/172110-solved-extracting-word-out-of-a-string/#findComment-907446 Share on other sites More sharing options...
play_ Posted August 27, 2009 Author Share Posted August 27, 2009 christ my code showed up full of quotes... completely forgot this forum use the same bbcode syntax. Thanks ignace, will look. Quote Link to comment https://forums.phpfreaks.com/topic/172110-solved-extracting-word-out-of-a-string/#findComment-907450 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.