Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update README.md

  • Loading branch information...
commit d4b781630b214c2c2e3040ad7a7525310109cfd6 1 parent 1370c5f
@Daniel15 authored
Showing with 6 additions and 0 deletions.
  1. +6 −0 README.md
View
6 README.md
@@ -11,10 +11,16 @@ Usage
=====
```javascript
+// Matching
var regexp = new NamedRegExp('Hello (?P<name>\\w+) from (?P<year>20[1-9][0-9])');
var results = regexp.exec('Hello Daniel from 2012');
alert(results.name) // "Daniel"
alert(results.year) // "2012"
+
+// Replacing
+var regexp = new NamedRegExp('^(?P<year>20[1-9][0-9]) is (?P<msg>.+)$');
+var result = '2012 is awesome'.replace(regexp, 'It\'s \\k<msg> in \\k<year>!');
+alert(result); // "It's awesome in 2012!"
```
Licence
Please sign in to comment.
Something went wrong with that request. Please try again.