Index: src/string.js |
diff --git a/src/string.js b/src/string.js |
index 3caaff43df91563faac196fd2d1a83bdb6fd200d..5fcd1e7eab17a06b5b9d815af48ca66e3407b7e0 100644 |
--- a/src/string.js |
+++ b/src/string.js |
@@ -592,12 +592,12 @@ function StringSplit(separator, limit) { |
return [subject]; |
} |
+ if (limit === 0) return []; |
+ |
var length = subject.length; |
if (!IS_REGEXP(separator)) { |
separator = TO_STRING_INLINE(separator); |
- if (limit === 0) return []; |
- |
var separator_length = separator.length; |
// If the separator string is empty then return the elements in the subject. |
@@ -608,8 +608,12 @@ function StringSplit(separator, limit) { |
return result; |
} |
- if (limit === 0) return []; |
+ // Separator is a regular expression. |
+ return StringSplitOnRegExp(subject, separator, limit, length); |
+} |
+ |
+function StringSplitOnRegExp(subject, separator, limit, length) { |
%_Log('regexp', 'regexp-split,%0S,%1r', [subject, separator]); |
if (length === 0) { |