一

{"type":"编程笔记"}


  • Home

  • Archives
  • Search

regexp.escape function of javascript

Posted on 2009-05-14   |   In javascript

RegExp.escape() function example

RegExp.escape = (function() {    var punctuationChars = /([.*+?|/(){}[\]\\])/g;    return function(text) {        return text.replace(punctuationChars, '\\$1');    }})();var str = RegExp.escape('a+b/c*d$ ^{.}');var reg = new RegExp(str);

References

  1. http://simonwillison.net/2006/Jan/20/escape
writeexcel tool for ruby
linux基础
  • Table of Contents
  • Overview
yuweijun

yuweijun

492 posts
12 categories
RSS
GitHub Twitter
  1. 1. RegExp.escape() function example
  2. 2. References
© 2021 yuweijun
Powered by Hexo
Theme - NexT.Mist.KISS