Skip to content
Browse files

Minor readme changes.

  • Loading branch information...
1 parent 347a62a commit 393af51ed1e9fb92c1ad4f5c3ec0e52beab8149a @slevithan committed Aug 22, 2012
Showing with 8 additions and 8 deletions.
  1. +8 −8
@@ -1,13 +1,13 @@
+[XRegExp]( 3.0.0-pre
XRegExp provides augmented, extensible JavaScript regular expressions. You get new syntax, flags, and methods beyond what browsers support natively. XRegExp is also a regex utility belt with tools to make your client-side grepping simpler and more powerful, while freeing you from worrying about pesky cross-browser inconsistencies and the dubious `lastIndex` property.
XRegExp supports all native ES5 regular expression syntax. It works with Internet Explorer 5.5+, Firefox 1.5+, Chrome, Safari 3+, and Opera 11+. You can also use it on the server with Node.js, or as a RequireJS module. The base library is about 3.8 KB, minified and gzipped.
## Performance
-XRegExp regexes compile to native `RegExp` regex objects, thus there is no performance difference between the two. There is a small extra cost the first time you compile a particular pattern and flags.
+XRegExp regexes compile to native `RegExp` objects, and therefore perform just as fast as native regular expressions. There is a small extra cost when compiling XRegExps, but even that is automatically cached so it's even faster the next time you compile the same pattern and flags.
## Usage examples
@@ -34,13 +34,13 @@ XRegExp.replace('2012-02-22', date, function(match) {
return match.month + '/' + + '/' + match.year;
}); // -> '02/22/2012'
-// In fact, all XRegExps are RegExps and work perfectly with native methods
+// In fact, XRegExps compile to RegExps and work perfectly with native methods
date.test('2012-02-22'); // -> true
// The *only* caveat is that named captures must be referenced using numbered backreferences
'2012-02-22'.replace(date, '$2/$3/$1'); // -> '02/22/2012'
-// If you want, you can extend native methods so you don't have to worry about this
+// If you want, you can extend native methods so you don't have to worry about this.
// Doing so also fixes numerous browser bugs in the native methods
'2012-02-22'.replace(date, '${month}/${day}/${year}'); // -> '02/22/2012'
@@ -61,14 +61,14 @@ XRegExp.matchChain('1 <b>2</b> 3 <b>4 a 56</b>', [
]); // -> ['2', '4', '56']
// You can also pass forward and return specific backreferences
-var html = '<a href="">XRegExp</a>\
- <a href="">Google</a>';
+var html = '<a href="">XRegExp</a>' +
+ '<a href="">Google</a>';
XRegExp.matchChain(html, [
{regex: /<a href="([^"]+)">/i, backref: 1},
{regex: XRegExp('(?i)^https?://(?<domain>[^/?#]+)'), backref: 'domain'}
]); // -> ['', '']
-// XRegExp.union safely merges strings and regexes into a single pattern
+// Merge strings and regexes into a single pattern, safely rewriting backreferences
XRegExp.union(['a+b*c', /(dogs)\1/, /(cats)\1/], 'i');
// -> /a\+b\*c|(dogs)\1|(cats)\2/i

0 comments on commit 393af51

Please sign in to comment.
Something went wrong with that request. Please try again.