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

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

What can cause "Required Package 'IndyCore' not found" when compiling a Delphi 2010 project? -