I'm new to regex with PHP. How can I find the contents of the first parentheses with a string that is a couple of paragraphs long.
I'm assuming I have to use the preg_match function
I'm new to regex with PHP. How can I find the contents of the first parentheses with a string that is a couple of paragraphs long.
I'm assuming I have to use the preg_match function
no need regex, just your normal PHP string functions
$str = "
yada yada yada
yada
yada yada
yada (bada bada
bada bada
bada) yada yada yada
yada yada
yada yada yada
( yo yo )
";
$s = explode(")",$str,2);
$what_i_want=$s[0];
$m = strpos($what_i_want,"("); #find where opening brace is
print substr($what_i_want,$m+1); #print from opening brace onwards