这是我的字符串($commit$ + $Bug$)/$HR$*($Leader$^$IT$)
...我想$variable$
用 1 替换所有替换...
像(1 + 1)/1*(1^1)
...
是否可以用值 1 替换???如何??
不在乎 $ _ _$ 之间的哪个变量...
请帮我...
$result = preg_replace(
'/\$ # Match $
\w+ # Match one or more alphanumeric characters
\$ # Match $/x',
'1', $subject);
这假设只有字符在和[A-Za-z0-9_]
之间是合法的。$
$
$str = '($commit$ + $Bug$)/$HR$*($Leader$^$IT$)';
$str = preg_replace('/\$(.*?)\$/', '1', $str);
echo $str;