[Note: Techy / Programming content]
I spent a while on Friday searching for a way to replace the Euro symbol (€) in content pulled from a text area, using Javascript (jQuery). As it took me some time to track down an answer, here it is:
var theContent = $('#theTextArea').val().replace(/\u20ac/g, 'Euro');
This replaces using a global search to find instances of the euro symbol, and replaces them with the word “Euro”. Using the actual Euro symbol (€) as the search pattern doesn’t work – so, for example, this won’t work:
.replace(/€/g, 'E');
Instead, this needs to be used: "\u20ac"
8 Comments
12:19 pm
Permalink
Great hint! You made my day…
7:01 pm
Permalink
thx. I don’t even know what that \u20ac code is but after trying &eur; and € I’m glad this does work!
7:15 pm
Permalink
No problem, glad it helped.
20AC is the unicode for the Euro symbol . (…and it took quite a bit of searching before I figured that out
).
8:53 am
Permalink
No problem Mike, glad it helped!
9:52 am
Permalink
Thanks Dave! That saved me a hair pulling search.You’re still making someone’s day a year later!
12:06 pm
Permalink
Thanks David!!! You just made Vera’s day
3:22 pm
Permalink
YES!!
Finally! Thanks for this, saved my day.
Took me forever to find this.
10:47 pm
Permalink
Thank thank thank. Too long thinking it was my terminal encoding going nuts again.