php - dreamweaver regex $1 escape in replace -
got this:
<?php echo mage::helper('checkout')->formatprice($tax['amount_incl_tax'],true,true); ?>
and have change in this:
<?php echo preg_replace('/(.*)([\d]{2})([^\d].*)?$/','$1<span class="cents">$2</span>$3',mage::helper('checkout')->formatprice($tax['amount_incl_tax'],true,true)) ?>
using regex.
how escape $1 in replace?
edit
ok question isn't clear.
i'm using dreamweaver manipulate php file.
i've got many strings ouput formatted price.
need add span tag style cents smaller rest.
need wrap each string in preg_replace() function.
stings need modify different got "formatprice" in it.
dreamweaver i'm goin modify strings using regex in find&replace.
new string contains "$1" , create conflict $1 dreamweaver backreference, need way escape it.
2 strings above in order example of got , should after find , replace.
i found work around this: php use \1 $1 backreference used setting in dramweaver find&replace:
- find:
([^\s]*formatprice.*\));?\s
- replace:
preg_replace('/(.*)([\d]{2})([^\d].*)?$/','\1<span class="cents">\2</span>\3',$1)
so don't need escape $1 anymore. still should interesting find out if there way use $1 in replace statment not backreference
Comments
Post a Comment