Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Aug 16, 2012
0 parents commit bfbdbe3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
components
build
11 changes: 11 additions & 0 deletions Makefile
@@ -0,0 +1,11 @@

build: components index.js
@component build

components:
@Component install

clean:
rm -fr build components template.js

.PHONY: clean
15 changes: 15 additions & 0 deletions Readme.md
@@ -0,0 +1,15 @@

# escape-regexp

Escape regular expression special characters.

## Example

```js
var escape = require('escape-regexp');
escape(str);
```

## License

MIT
10 changes: 10 additions & 0 deletions component.json
@@ -0,0 +1,10 @@
{
"name": "escape-regexp",
"description": "Escape regular expression special characters",
"version": "0.0.1",
"keywords": ["escape", "regexp", "utility"],
"dependencies": {},
"scripts": [
"index.js"
]
}
12 changes: 12 additions & 0 deletions index.js
@@ -0,0 +1,12 @@

/**
* Escape regexp special characters in `str`.
*
* @param {String} str
* @return {String}
* @api public
*/

module.exports = function(str){
return String(str).replace(/([.*+?=^!:${}()|[\]\/\\])/g, '\\$1');
};

0 comments on commit bfbdbe3

Please sign in to comment.