Brett Pontarelli
Brett Pontarelli

Reputation: 1728

How do I do a RegExp replace inside a jQuery template?

Suppose I have

{ price: '$ 9.99 USD' }

and in my jQuery template I want to do this

{{html String(price).replace(/([^A-Z ]+)/gi, '<em>$1</em>')}}

Check out this fiddle and notice the change in output that adding/removing the $1 makes: http://jsfiddle.net/brettwp/KNAtz/

Upvotes: 0

Views: 2483

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 191016

Is $& what you want?

http://jsfiddle.net/KNAtz/5/

Upvotes: 3

Related Questions