php - strip text with regex -


i want extract text between [ , ] regex in php:

example input:

hello, [good] test [regex] test 

desired output:

good regex 

how can extract them?

use regex /\[(.*?)\]/

<?php $str='hello, [good] test [regex] test'; preg_match_all('/\[(.*?)\]/', $str, $matches); print_r($matches[1]); 

output :

array (     [0] =>     [1] => regex ) 

enter image description here


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -