如何使用PHP preg_匹配冒号和句点之间的文本?
我有这个字符串:如何使用PHP preg_匹配冒号和句点之间的文本?,php,regex,preg-match,Php,Regex,Preg Match,我有这个字符串: $style = "width:87.0%;"; 如何使用PHP preg_match()从中提取“87”?为了我的生命,我不能让我的头套围绕着regex:( ?使正则表达式不情愿/不受约束 preg_match('~:(\d+)\.~', 'width:87.0%;', $m); print_r($m); print $m[1]; // 87 \d仅限数字,+一次或多次,()将其分组(捕获)以供以后使用 preg_match('~:(\d+)\.~', 'width:87
$style = "width:87.0%;";
如何使用PHP preg_match()从中提取“87”?为了我的生命,我不能让我的头套围绕着regex:(
?
使正则表达式不情愿/不受约束
preg_match('~:(\d+)\.~', 'width:87.0%;', $m);
print_r($m);
print $m[1]; // 87
\d
仅限数字,+
一次或多次,()
将其分组(捕获)以供以后使用
preg_match('~:(\d+)\.~', 'width:87.0%;', $m);
print_r($m);
print $m[1]; // 87