I have a webpage where I want to replace all standard quote characters " with the nicer looking quotes. For example, we have
"hello world"
which would be replaced with
“hello world”
in markup, showing the much better looking ‘curly’ quotes.
The two HTML special characters are pairs, in that they “open” and “close” a quote block, instead of being a generic double dash, which is where I’m struggling – simply replacing all quotes with “ is easy, but I want to do it so the open/close pairs are respected.
I might be missing something obvious here, but I think the following RegEx solution would work –
If you were using PHP then you could write some similar code in PHP – (my PHP skills are somewhat lacking though! The code below was generated with RegEx Buddy so it hasn’t been tested and may need changing)
Alternatively, you could load the content into a DIV using PHP then use JavaScript to change the DIV contents, here’s a bit of JQuery that would do the job –
There’s a jsfiddle that demonstrates the above JQuery here.