regex - Php preg_match to capture only specific phrases -
example string:
$string = 'text text text text {capture this1, this2} text text text text'; i want use preg_match, these this1, , this2 in array , nothing else.
i trying so:
$array = array(); $reg = '/\{capture.*\}/'; //this needs changing preg_match($reg, $string, $array); var_dump($array); this captures {capture this1, this2}. how exclude '{' sign regex? trying .!\{ gave me errors. suggestions?
you can try following regex:
/\{(capture[^}]*)\}/
Comments
Post a Comment