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

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -