diff options
| author | Jens Mönig <jens@moenig.org> | 2014-11-24 13:32:55 +0100 |
|---|---|---|
| committer | Jens Mönig <jens@moenig.org> | 2014-11-24 13:32:55 +0100 |
| commit | f99962c1613cccea7ce5fa70dc8595a767e15a1b (patch) | |
| tree | 456a95f7128e7658d9792cd23f2906041bb3dc00 | |
| parent | 591a8d598f98a159df435c79cdf6020b0c1fca85 (diff) | |
| parent | 3e8146d043b1f1dc6f37e0a8cbd2e5d3dafb90c7 (diff) | |
| download | snap-f99962c1613cccea7ce5fa70dc8595a767e15a1b.tar.gz snap-f99962c1613cccea7ce5fa70dc8595a767e15a1b.zip | |
Merge pull request #619 from cycomachead/split
Improvements to Split block for whitespace and line options
| -rw-r--r-- | threads.js | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -2159,15 +2159,17 @@ Process.prototype.reportTextSplit = function (string, delimiter) { str, del; if (!contains(types, strType)) { - throw new Error('expecting a text instad of a ' + strType); + throw new Error('expecting text instead of a ' + strType); } if (!contains(types, delType)) { - throw new Error('expecting a text delimiter instad of a ' + delType); + throw new Error('expecting a text delimiter instead of a ' + delType); } str = (string || '').toString(); switch (this.inputOption(delimiter)) { case 'line': - del = '\r?\n'; + // Unicode Compliant Line Splitting (Platform independent) + // http://www.unicode.org/reports/tr18/#Line_Boundaries + del = /\r\n|[\n\v\f\r\x85\u2028\u2029]/; break; case 'tab': del = '\t'; @@ -2176,7 +2178,9 @@ Process.prototype.reportTextSplit = function (string, delimiter) { del = '\r'; break; case 'whitespace': - return new List(str.trim().split(/[\t\r\n ]+/)); + str = str.trim(); + del = /\s+/; + break; case 'letter': del = ''; break; |
