Path: csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Splitting strings (was: Any way to do this in JavaScript?) Supersedes: <2842585.44csPzL39Z@PointedEars.de> Date: Wed, 20 Jul 2016 00:25:09 +0200 Organization: PointedEars Software (PES) Lines: 68 Message-ID: <7188767.T7Z3S40VBb@PointedEars.de> References: <1889594.irdbgypaU6@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1468967110 25230 eJwFwQkRwEAIBDBLB8vCIIen+JfQhHDxCXO68XijHV/kniLKn6ZBd0izN5xHoiRRvuhqif4BEhoQvw== (19 Jul 2016 22:25:10 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 19 Jul 2016 22:25:10 +0000 (UTC) User-Agent: KNode/4.14.2 Cancel-Key: sha1:EZxfC4G6XzyaUzEC7Qku5kPPS+M= X-User-ID: eJwNyMEBwCAIA8CVAiUg4yjI/iPYex4/F68wpxuHcwlghN6kyaRmpQmWrsDJtihuR+Qc+t/bbmOFaoseFuoBHmkUPA== Cancel-Lock: sha1:K5k4bXUemNztgOJ/kKpO6ireU60= X-NNTP-Posting-Host: eJwFwQEBwDAIAzBNG6VwOXSAfwlP3Hj4AnTC13dF1XVmnhc67boxlVo0+gvVWGHGJtWdhh8zNBIo Xref: csiph.com comp.lang.javascript:30921 $Bill wrote: > On 7/19/2016 12:05, Thomas 'PointedEars' Lahn wrote: > > Thanks for your further clarification of the issue. You’re welcome. >> Note that while in Perl your delimiter is always considered a regular ^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> expression (see perlfunc(1)), in ECMAScript implementations it can be ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >> either a string value or a regular expression. In this case, using a >> string value as you did is the proper, most efficient, approach. > > If you're referring to the split delimiter/pattern, it can be an RE or a > string in Perl. You are missing the point: | $ perl -We 'use strict; print(join(",", split("o+", "foobar")), "\n");' | f,bar | | $ perl -We 'use strict; print(join(",", split(/o+/, "foobar")), "\n");' | f,bar | | $ perl -v | head -n 2 | | This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64-linux- | gnu-thread-multi vs. | $ js -e '"use strict"; console.log("foobar".split("o+").join(","));' | foobar | | $ js -e '"use strict"; console.log("foobar".split(/o+/).join(","));' | f,bar | | $ js --help | head -n 1 | Usage: node [options] [ -e script | script.js ] [arguments] | | $ js -v | v0.10.38 >> Details can be found there and resources referred there. >> Next time, post with your real name. This is Usenet, not a chat room. > > It's a nickname. I used it for 21 years at JPL/NASA Good for you. > and it was good enough for them ... […] As you can see in my postings, nicknames are used differently in Usenet (nowadays). Also, you should choose the Subject header field value more wisely next time (as I should have earlier). See the FAQ on posting for details. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.