regex - preg_match() text extraction -
i have string inside paragraph:
today's quote is: 'learn yesterday, live today, hope tomorrow. important thing not stop questioning.'
i need extract sentence "learn yesterday, live today, hope tomorrow. important thing not stop questioning."
i not familiar regular expressions little here. tried:
preg_match("today's quote is: '[a-za-z0-9]'",$response, $matches);
off course imagined it's not working. appreciated. in advance.
edit: need include "_" , "-" alphanumeric expression.
example:
$string = "site : '6lczwncsaaaaaecqkyccsteouaqs9jo7wdrgzvbl', rtl : false, challenge : '03ahj_vuv_3y7ky-gqacyzgrz9ztv_cfqn_f0jeqognq0-3qanrsxj18opj4bbhrqpoisizbqbbdeexvfpnnvjltsjoxqugi4j0zb1yrqu1m4wxzfgvrpuryxjmnju3d7ix0nhyo_obefcr7v9gxtz_bnn04tszxxvyvkcexo9i2vcqcihwjqe8k8'";
i need match string after word "challenge". containing underscores , "-".
this should job:
$string = "today's quote is: 'learn yesterday, live today, hope tomorrow. important thing not stop questioning.'"; preg_match('/.*?:.*?\'(.*?)\'/', $string, $m); echo $m[1]; // learn yesterday, live today, hope tomorrow. important thing not stop questioning.
edit2: after op has shown example. here's solution edit:
$string = "site : '6lczwncsaaaaaecqkyccsteouaqs9jo7wdrgzvbl', rtl : false, challenge : '03ahj_vuv_3y7ky-gqacyzgrz9ztv_cfqn_f0jeqognq0-3qanrsxj18opj4bbhrqpoisizbqbbdeexvfpnnvjltsjoxqugi4j0zb1yrqu1m4wxzfgvrpuryxjmnju3d7ix0nhyo_obefcr7v9gxtz_bnn04tszxxvyvkcexo9i2vcqcihwjqe8k8'"; preg_match_all('/.*?:.*?\'(.*?)\'/', $string, $m); var_dump($m);
Comments
Post a Comment