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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -