Now uses greedy replacement. Fixes #1

This commit is contained in:
Eric Wood 2013-04-07 14:57:44 -05:00
parent 41ea00390e
commit bd6fd498aa
1 changed files with 7 additions and 2 deletions

View File

@ -1,8 +1,13 @@
excelParser = {
latexEscape: function(text) {
escapeRegExpr = function(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
};
var specials = ['\\', '&', '%', '$', '#', '_', '{', '}', '~', '^'];
$.each(specials, function(i,special) {
text = text.replace(special, '\\' + special);
$.each(specials, function() {
var regexp = new RegExp(escapeRegExpr(this), 'g');
text = text.replace(regexp, '\\' + this, 'g');
});
return text;