Title: [Plugin: Content Molecules] Minor bug in using $ inside value strings
Last modified: August 20, 2016

---

# [Plugin: Content Molecules] Minor bug in using $ inside value strings

 *  [drtonyb](https://wordpress.org/support/users/drtonyb/)
 * (@drtonyb)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-content-molecules-minor-bug-in-using-inside-value-strings/)
 * Great little plugin Marcus, but I’ve encountered a small bug.
 * Consider using [m id=”test” price=”$10.00″] when the test template is “Price:{
   price}”
 * You get in your output
 * Price: .00
 * Since this example is effectively processed using
 * `preg_replace('/{price}/i', '$10.00', 'Price: {price}');`
 * the $10 is interpreted by preg_replace as the 10th parenthesized match in the
   pattern – this means the $10 is stripped from the replacement string resulting
   in the price of .00.
 * If you try [m id=”test” price=”$100.00″], the output will be Price: 0.00 because
   the $n feature only allows n from 0 to 99, so $10 is stripped.
 * Not sure why you’re using preg_replace here since it is a simple string replacement,
   so I think you could use str_ireplace for this part of your code and avoid this
   problem.
 * Alternatively, you could replace $ in the replacement string with \$ before using
   preg_replace.
 * Tony
 * [http://wordpress.org/extend/plugins/content-molecules/](http://wordpress.org/extend/plugins/content-molecules/)

The topic ‘[Plugin: Content Molecules] Minor bug in using $ inside value strings’
is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/content-molecules.svg)
 * [Content Molecules](https://wordpress.org/plugins/content-molecules/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/content-molecules/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/content-molecules/)
 * [Active Topics](https://wordpress.org/support/plugin/content-molecules/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/content-molecules/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/content-molecules/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [drtonyb](https://wordpress.org/support/users/drtonyb/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-content-molecules-minor-bug-in-using-inside-value-strings/)
 * Status: not resolved