Skip to content

Commit 2a82945

Browse files
committed
misc minor; update /build files
1 parent 2aee011 commit 2a82945

File tree

7 files changed

+145
-32
lines changed

7 files changed

+145
-32
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[XRegExp](http://xregexp.com/) 3.0.0-pre
22
========================================
33

4-
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.
4+
XRegExp provides augmented and 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.
55

66
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.
77

8+
See [what's new in version 3.0.0-pre](https://github.com/slevithan/xregexp/wiki/Roadmap).
9+
810
## Performance
911

1012
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 a pattern for the first time.

build/xregexp-all-min.js

Lines changed: 103 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/xregexp-min.js

Lines changed: 21 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/xregexp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ var XRegExp = (function(undefined) {
11991199

12001200
// Rewrite backreferences. Passing to XRegExp dies on octals and ensures patterns
12011201
// are independently valid; helps keep this simple. Named captures are put back
1202-
output.push(self(pattern.source).source.replace(parts, rewrite));
1202+
output.push(nativ.replace.call(self(pattern.source).source, parts, rewrite));
12031203
} else {
12041204
output.push(self.escape(pattern));
12051205
}

tests/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
<script src="vendor/jasmine/jasmine-html.js"></script>
1111

1212
<!-- XRegExp -->
13+
<!--<script src="../build/xregexp-all-min.js"></script>-->
14+
<!--<script src="../build/xregexp-min.js"></script>-->
1315
<script src="../src/xregexp.js"></script>
1416
<script src="../src/addons/build.js"></script>
1517
<script src="../src/addons/matchrecursive.js"></script>

tests/perf/perf.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@
141141
var matches = [];
142142
if (!r.global) {
143143
//r = XRegExp.globalize(r);
144-
r = new RegExp(r.source, 'g' + (r.ignoreCase ? 'i' : '') + (r.multiline ? 'm' : ''));
144+
r = new RegExp(r.source, 'g' +
145+
(r.ignoreCase ? 'i' : '') +
146+
(r.multiline ? 'm' : '') +
147+
(r.sticky ? 'y' : ''));
145148
}
146149
str.replace(r, function(match) {
147150
matches.push(match);
@@ -151,11 +154,14 @@
151154
var r = /^|(((?=x).)\2)+/;
152155
var matches = [];
153156
var match;
154-
if (!r.global) {
155-
//r = XRegExp.globalize(r);
156-
r = new RegExp(r.source, 'g' + (r.ignoreCase ? 'i' : '') + (r.multiline ? 'm' : ''));
157-
} else {
157+
if (r.global) {
158158
r.lastIndex = 0;
159+
} else {
160+
//r = XRegExp.globalize(r);
161+
r = new RegExp(r.source, 'g' +
162+
(r.ignoreCase ? 'i' : '') +
163+
(r.multiline ? 'm' : '') +
164+
(r.sticky ? 'y' : ''));
159165
}
160166
while (match = r.exec(str)) {
161167
matches.push(match[0]);
@@ -176,10 +182,9 @@
176182
})
177183
.add('XRegExp.forEach', function() {
178184
var r = /^|(((?=x).)\2)+/;
179-
var matches = [];
180-
XRegExp.forEach(str, r, function(match) {
181-
matches.push(match[0]);
182-
});
185+
var matches = XRegExp.forEach(str, r, function(match) {
186+
this.push(match[0]);
187+
}, []);
183188
})
184189
);
185190
}());

xregexp-all.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ var XRegExp = (function(undefined) {
12261226

12271227
// Rewrite backreferences. Passing to XRegExp dies on octals and ensures patterns
12281228
// are independently valid; helps keep this simple. Named captures are put back
1229-
output.push(self(pattern.source).source.replace(parts, rewrite));
1229+
output.push(nativ.replace.call(self(pattern.source).source, parts, rewrite));
12301230
} else {
12311231
output.push(self.escape(pattern));
12321232
}

0 commit comments

Comments
 (0)