Skip to content

Instantly share code, notes, and snippets.

@tedzhou
Created June 9, 2013 08:00
Show Gist options
  • Save tedzhou/5742746 to your computer and use it in GitHub Desktop.
Save tedzhou/5742746 to your computer and use it in GitHub Desktop.
wrap regex key words
/**
* Created with IntelliJ IDEA.
* User: ted
* Date: 13-6-9
* Time: 下午3:59
* To change this template use File | Settings | File Templates.
*/
// copy from canjs
// 把正则的敏感词转起来
var wrapQuote = function(str) {
return (str+'').replace(/([.?*+\^$\[\]\\(){}|\-])/g, "\\$1");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment