在从Adobe Illustrator(AI)文件导出到SVG的过程中,我得到了没有任何单位的字体大小样式。所以我需要用单位来更新字体大小部分。
如何使用preg_replace替换主题?
font-size:6.3875;
至
font-size:6.3875px;
您可以使用:
$input = preg_replace('/(font-size's*:'s*[^;]+);/i', '$1px;', $input);
RegEx演示
(.*?);
更换为
'1px;
这应该行得通。
你不需要捕获任何东西,
<?php
$mystring = 'font-size:6.3875;';
$re = "px";
echo preg_replace("~(?=;$)~", $re, $mystring);
?>
输出:
font-size:6.3875px;