Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30921
| Path | csiph.com!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| 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> (permalink) |
| References | <nmln2h$kbr$1@dont-email.me> <1889594.irdbgypaU6@PointedEars.de> <nmm07r$mmi$1@dont-email.me> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| 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 |
Show key headers only | View raw
$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
>> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split>
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: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Any way to do this in JavaScript? $Bill <news@todbe.com> - 2016-07-19 10:12 -0700
Re: Any way to do this in JavaScript? Martin Honnen <martin.honnen@gmx.de> - 2016-07-19 20:14 +0200
Re: Any way to do this in JavaScript? $Bill <news@todbe.com> - 2016-07-19 12:02 -0700
Re: Any way to do this in JavaScript? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-19 21:05 +0200
Re: Any way to do this in JavaScript? $Bill <news@todbe.com> - 2016-07-19 12:49 -0700
Splitting strings (was: Any way to do this in JavaScript?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-20 00:25 +0200
Re: Splitting strings (was: Any way to do this in JavaScript?) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-20 09:45 +0200
Re: Any way to do this in JavaScript? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-07-19 23:21 -0700
Re: Any way to do this in JavaScript? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-20 10:56 +0200
csiph-web