I need to replace all integers after and before these specific characters: ( ) * - / % + space
but nothing than these.
So (34 +
should match but a34 +
or k3-
should not.
I have this so far, '/(?:-| |\\(|\\)|\\+|\\*|\\/|%)(\\d+)(?:-| |\\(|\\)|\\+|\\*|\\/|%)/'
but this is not working like what I want it to.
$pattern = '/[- ()+*\/%](\d+)[- ()+*\/%]/';
$replacement = "xyz($1)";
$insideFunc = preg_replace($pattern, $replacement, $insideFunc);
$insideFunc = "float y = 45*(3-max(3-float(ceil(3)), 3-float(floor(3))))*2.302585092994046"
output -> float y =xyz(45)xyz(3)maxxyz(3)float(ceilxyz(3)),xyz(3)float(floorxyz(3))))*2.302585092994046
I want it to be, float y = xyz(45)*(xyz(3)-max(xyz(3)-float(ceil(xyz(3))), xyz(3)-float(floor(xyz(3)))))*2.302585092994046
I changed it like that and it's working now.
$pattern = '/([- ()+*\/%])(\d+)([- ()+*\/%])/';
$replacement = "$1float($2)$3";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.