Skip to content

Commit

Permalink
Avoid matching on single quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
mbiggin committed May 17, 2015
1 parent 32d055e commit 5b23f78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ test('Capitalize each word', function (t) {
})
```

And ensure that quotes are handled within the string:

```javascript
test('Capitalize each word ensuring that quotes do not confuse it', function(t) {
t.plan(1)
t.equal(capitalize.words("it's a nice day"), "It's A Nice Day")
})
```

## Install

npm install capitalize
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function (string) {
}

module.exports.words = function (string) {
return string.replace(/(^|\W)(\w)/g, function (m) {
return string.replace(/(^|[^a-zA-Z0-9_'])(\w)/g, function (m) {
return m.toUpperCase()
})
}

0 comments on commit 5b23f78

Please sign in to comment.