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 )
Comments
Post a Comment