Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30921
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Splitting strings (was: Any way to do this in JavaScript?) |
| Date | 2016-07-20 00:25 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <7188767.T7Z3S40VBb@PointedEars.de> (permalink) |
| References | <nmln2h$kbr$1@dont-email.me> <1889594.irdbgypaU6@PointedEars.de> <nmm07r$mmi$1@dont-email.me> |
$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